Need Help With Basic Java Commands

Started by
4 comments, last by Longbaugh 20 years, 11 months ago
Know that i have got you to read this... I am doing a 2d shooter program for school, and need HELP, please for the love of all that is good in this world, i need help. Any and i mean any, and ALL!!!! site are needed. If you have any source code, links, ideas, general concepts, or past experience, etc.. PLEASE PLEASE PLEASE... HELP ME and the rest of my group. =(
Advertisement
www.javagaming.org
Longbaugh this is the kind of post that makes people''s blood boil. The forums are for asking and answering specific questions, not blanket requests for help. If you have something more specific than "PLEASE PLEASE PLEASE HELP ME" then ask and people here will gladly do what they can. What do you need help with? Do you know how to program at all? Do you understand the concept of a game loop? Do you know how to read files and display graphics? Etc.

On top of that (somewhat off topic though), if you''re creating a program for school did it occur to you that what you''re doing is dishonest, bordering on cheating? As it is you''re essentially asking other people to do your work/research for you.
sorry , i have somehow insulted you or this page but as it stands the project is overdue. And we do need help in a broad range of areas.
Currently we are making the class file to create and array of pre made bullet objects, with methods inside that control motion and collision detection, that can be called into the game loop indepent of other bullets and without having to create a hoard of variables and if statements. the main thing is we can''t figure out how to get the darn thing to paint onto our applet from a seperate class file.

this is only the tip of the iceberg....
if you need more clarification just ask
ROFL, sounds like he''s running out of time on a due date for a project
If you want your bullet to have it''s own paint method that can paint onto your applet, just pass the class the Graphics object from your applet''s paint method and paint onto it. For example,
this is in you main class:

public void paint(Graphics g)
{
//...some code
for(int j = 0; j < num_bullets; ++j)
bullet[j].draw(g);
//some other code...
}

... now in your bullet class

public void draw(Graphics g)
{
g.fillRect(x,y,w,h);
}

If your bullet has an Image that it needs to draw, you need to also pass the instance of your applet to the bullet so it can use drawImage:

public void paint(Graphics g)
{
//...some code
for(int j = 0; j < num_bullets; ++j)
bullet[j].draw(g, this);
//some other code...
}

... now in your bullet class

public void draw(Graphics g, Applet a)
{
g.drawImage(image,x,y,a);
}

Just be sure to import java.applet.*; so your bullet class knows what a Graphics object is.

This topic is closed to new replies.

Advertisement