Hello there, Java-Gaming people. I’m new to the forum, so maybe a little introduction is in order. So I’m this guy from the Netherlands, I have programmed in Gamemaker quite extensively, with which I started at a young age. Mind you I didn’t do the Drag and Drop stuff, but “proper” coding, and I have in gamemaker constructed some stuff that I think is pretty nifty, I have for example at a point programmed an online top down shooter from scratch (as far as that goes in gamemaker). However, this year at university (First year Software Science), I was introduced to Java, and after some tests I found out that it is an insane amount faster then Gamemaker, so I decided to move to Java, and I have succeeded(sp?) in creating a simple mario platformer, with image animations, a particle system and some gibberish, but I have now moved on to a new more structured project (An isometric RTS), BUT somewhere something must be going wrong because it does not draw images.
Tl;dr:
This is an extract from my script, this is the image initialization:
public class Tile extends GameImage
{
int x,y;
int type;
TileGrid grid;
Image image=Toolkit.getDefaultToolkit().getImage("Grass.png");
And this is the “draw” script, which I know to work, since it does draw the lines, but it does not draw the image, and I have no idea why.
public void draw(Graphics2D g)
{
int dx,dy;
dx=grid.X(x);
dy=grid.Y(y);
g.drawImage(image,dx-16,dy-8,null);
g.drawLine(dx-16,dy,dx,dy-8);
g.drawLine(dx,dy-8,dx+16,dy);
g.drawLine(dx-16,dy,dx,dy+8);
g.drawLine(dx,dy+8,dx+16,dy);
}
Help would be appreciated (:, in the meanwhile this forum has quite some resources and information to absorb.