simple questions

i've been looking around and learning, enough to make a simple game, this is what i've got so far.

import java.applet.*;

import java.awt.*;

import java.awt.image.*;

import java.awt.event.*;

publicclass Correextends Appletimplements Runnable, MouseMotionListener

{

int ancho = 500;// Ancho del applet

int alto = 500;// Alto del applet

int naveX = 120;// Coordenada X de la nave

int naveY = 120;// Coordenada Y de la nave

Thread hiloJuego;// El hilo...

Image nave;// Imagen para la nave

Graphics2D bufferdImgSurface;// Variables graficas para

BufferedImage bufferdImg;// usar double buffer

publicvoid start()

{

Thread hiloJuego =new Thread(this);

hiloJuego.start();

}

publicvoid init()

{

nave = getImage(getDocumentBase(),"rType.gif");

bufferdImg = (BufferedImage)createImage(ancho, alto);

bufferdImgSurface = bufferdImg.createGraphics();

addMouseMotionListener(this);

}

publicvoid run()

{

while(true)// Comienza el ciclo

{

repaint();// Redibuja la pantalla en cada ciclo

}

}

publicvoid paint(Graphics g)

{

update(g);

}

publicvoid update(Graphics g)

{

Graphics2D g2 = (Graphics2D)g;

// Color de fondo.

bufferdImgSurface.setBackground(Color.black);

// Limpia el applet.

bufferdImgSurface.clearRect(0, 0, ancho, alto);

// Dibuja la nave en posicion actual.

bufferdImgSurface.drawImage(nave, naveX, naveY,this);

// Dibuja todo lo anterior en pantalla

g2.drawImage(bufferdImg, 0, 0,this);

}

publicvoid mouseMoved(MouseEvent e){ naveX=e.getX(); naveY=e.getY();}

publicvoid mouseDragged(MouseEvent e){ naveX=e.getX(); naveY=e.getY();}

publicvoid mouseReleased(MouseEvent e){}

}

Okay, so it's just only a ship that can be controled by the mouse on a black background, it's not much, I know...(still impressive for someone that didn't know what an applet was a week ago).

my questions:

1.When I move the ship the mouse pointer covers it, any way i can make the arrow go away?

2.Is there any special method to put a background image or can I just put it there like i put the ship(i'm plannig to put an animated gif, so it gives you a sense of movement).

3. this has nothing to do with programming, but i'm making this game after an old atari game where you controlled a rocket and you had to dodge stuff(the rocket didn't shoot). anyone remembers the name of that game?

[4816 byte] By [ja_cach_vaa] at [2007-9-29 16:03:46]
# 1

1. I've found the best way to remove the cursor is to create a custom cursor from an image that has a transparent gif as it's main image- this way the cursor is still there, but can;t be seen. I don't know of anyway of completely removing the cursor.

2. I would draw the background image to a separate graphics object or image before painting it onto the background. Alternatively you could ahve a panel that sits in the background, but this may be overkill.

3. No idea about the gaem- sorry!! Do a search on google and you may come up trumps!!!

Marc

heyhoe_ma at 2007-7-15 14:12:36 > top of Java-index,Other Topics,Java Game Development...
# 2

>1. I've found the best way to remove the cursor is to

>create a custom cursor from an image that has a

>transparent gif as it's main image- this way the

>cursor is still there, but can;t be seen. I don't know

>of anyway of completely removing the cursor.

getToolkit().createCustomCursor(

getToolkit().getImage(""),new Point(0,0), "");

the above will make a cursor with no image at all so you don't even

need that tranparent image.

afarmanda at 2007-7-15 14:12:36 > top of Java-index,Other Topics,Java Game Development...
# 3
<*******> impressive my ***, i had pong up and running in 3 days, it even had speed increments, double buffering and threading. All from the little red dot in the clickme applet! memeber that? </*******>
penguins404a at 2007-7-15 14:12:36 > top of Java-index,Other Topics,Java Game Development...
# 4
Thanks a lot everyone, I'm moving along very well, now i'm doing everything in separate classes instead of just jamming the applet with code. If I have questions i know where to ask :)
ja_cach_vaa at 2007-7-15 14:12:36 > top of Java-index,Other Topics,Java Game Development...
# 5

I used:

getToolkit().createCustomCursor(getToolkit().getImage(""),new Point(0,0), "");

But when i ran the game I get a weird IO protection error.

I changed the code to this:

getToolkit().createCustomCursor(getImage(getDocumentBase(), ""),new Point(0,0), "");

the error does not happen, but the cursor does not dissapear either =/

ja_cach_vaa at 2007-7-15 14:12:36 > top of Java-index,Other Topics,Java Game Development...
# 6
BufferedImage cur = new BufferedImage(1, 1, BufferedImage.TYPE_4BYTE_ABGR);setCursor(getToolkit().createCustomCursor(cur,new Point(0,0),""));
Woogleya at 2007-7-15 14:12:36 > top of Java-index,Other Topics,Java Game Development...