This may just be something with the first time running (I Dunno)
[quote]Issue #2: Are you sure you extracted both of the image files, player_16x16.png and cake_16x16.png?
[/quote]
Yes
CopyableCougar4
[/quote]
I have no idea what might be going on: If you want to try compiling the source code, here you go (1 class, 100 or-so lines):
import java.awt.Graphics;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import com.darkcart.lib.sjgl.BasicGame;
import com.darkcart.lib.sjgl.Window;
import com.darkcart.lib.sjgl.simplegl.Font;
import com.darkcart.lib.sjgl.simplegl.GL;
import com.darkcart.lib.sjgl.sound.PlayMIDI;
import com.darkcart.lib.sjgl.util.Color;
import com.darkcart.lib.sjgl.util.RandomInt;
public class FindTheCake extends BasicGame implements KeyListener {
private static final long serialVersionUID = 1L;
// Globals
public Window win;
public GL gl;
public int playerX = 300;
public int playerY = 140;
public int cakeX = 50;
public int cakeY = 140;
public int cakeFound = 0;
public void init() {
gl = new GL();
PlayMIDI midi = new PlayMIDI();
midi.loadMidi("Ringo's Theme (This Boy).mid");
midi.playMidi();
// Creating Window
win = new Window();
win.createWindow("Find The Cake", 640, 480, false);
win.addTool(this);
// Adding KeyListener to Window
win.addKeyListener(this);
win.setFocusable(true);
}
public void paint(Graphics g) {
// Drawing text, images, background
gl.init(g);
gl.background(Color.lightGreen);
gl.text("Find The Cake", Color.black, new Font("Helvetica", Font.PLAIN, 24), 230, 30);
gl.text("Cake!", cakeX, cakeY);
gl.text("Cake Found: " + cakeFound, new Font("Helvetica", Font.BOLD, 12), 10, 10);
gl.loadImage("player_16x16.png");
gl.image(playerX, playerY, 64, 64);
gl.loadImage("cake_16x16.png");
gl.image(cakeX, cakeY, 64, 64);
logic();
}
public void logic() {
// Collisions
if (playerX == cakeX && playerY == cakeY || playerX == cakeX + 40 && playerY == cakeY
|| playerX == cakeX - 40 && playerY == cakeY) {
cakeFound++;
newPosition();
}
}
public void newPosition() {
RandomInt rand = new RandomInt();
int rand1 = rand.nextInt(500);
cakeX = rand1;
repaint();
}
// KeyListener (inherited) methods
public void keyPressed(KeyEvent e) {
int keyCode = e.getKeyCode();
if (keyCode == KeyEvent.VK_W) {
playerY = playerY - 1;
repaint();
}
if (keyCode == KeyEvent.VK_S) {
playerY = playerY + 1;
repaint();
}
if (keyCode == KeyEvent.VK_A) {
playerX = playerX - 1;
repaint();
}
if (keyCode == KeyEvent.VK_D) {
playerX = playerX + 1;
repaint();
}
}
public void keyReleased(KeyEvent e) {
}
public void keyTyped(KeyEvent e) {
}
public static void main(String[] args) {
FindTheCake ftc = new FindTheCake();
ftc.init();
}
}