comanighttrain
Senior Newbie 
|
 |
«
Posted
2006-01-23 02:30:54 » |
|
Hey guys, Im trying to program an offline platform shooter, iv scoured the net for a few hours and cant find any tutorials or resources for game programming without the applet.
Iv tried to work it out myself by embedding the applet in a JFrame, but that didnt help because you need to repaint the whole lot or else you end up with trailing, plus im pretty sure its not the best way to program it.
Can anyone point me to tutorials or resources that deals with this subject? thanks, Dave
|
|
|
|
|
|
|
comanighttrain
Senior Newbie 
|
 |
«
Reply #2 - Posted
2006-01-23 22:17:48 » |
|
suuweeet! thanks a lot man 
|
|
|
|
|
Games published by our own members! Check 'em out!
|
|
comanighttrain
Senior Newbie 
|
 |
«
Reply #3 - Posted
2006-01-23 23:26:27 » |
|
Hmm...this is odd, this tutorial wont compile because Game makes referance to AlienShip, and AlienShip makes a referance to game...
|
|
|
|
|
oNyx
|
 |
«
Reply #4 - Posted
2006-01-23 23:34:01 » |
|
X:\foo\spaceinvaders.zip\spaceinvaders>javac org/newdawn/spaceinvaders/Game.java Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details.
X:\foo\spaceinvaders.zip\spaceinvaders>java org.newdawn.spaceinvaders.Game
Works just fine here.
|
|
|
|
comanighttrain
Senior Newbie 
|
 |
«
Reply #5 - Posted
2006-01-24 00:24:33 » |
|
if i compile "game.java" in jcreator it says "cannot symbol class AlienEntity"
Javac is not recognised by my command line, grrr, this is what happens when i switch from linux to windows, im not good at configuring this.
|
|
|
|
|
comanighttrain
Senior Newbie 
|
 |
«
Reply #6 - Posted
2006-01-24 00:46:37 » |
|
nope, just got javac working properly and same problem.
|
|
|
|
|
swpalmer
|
 |
«
Reply #7 - Posted
2006-01-24 01:01:22 » |
|
Your classpath or source file path is not properly configured.
Did you use the -sourcepath arg to javac?
Java uses a multipass compiler so there is no problem with circular references like Game->Ship and Ship->Game.
|
|
|
|
comanighttrain
Senior Newbie 
|
 |
«
Reply #8 - Posted
2006-01-24 01:09:19 » |
|
no...i just used
javac Game.java
Sorry, i must be frustrating you guys by now, we always compiled from IDE's so im not used to the command line args.
|
|
|
|
|
kevglass
|
 |
«
Reply #9 - Posted
2006-01-24 01:48:45 » |
|
No problem, seems to be a common one, its probably to do with the package that Game is in. You see in onyx's example he did this: javac org/newdawn/spaceinvaders/Game.java
because you need to compile from the base of the package structure and because Game is in the package "org.newdawn.spaceinvaders". Kev
|
|
|
|
Games published by our own members! Check 'em out!
|
|
comanighttrain
Senior Newbie 
|
 |
«
Reply #10 - Posted
2006-01-24 02:07:12 » |
|
 I have just tried that in cmd.exe, its still giving me 24 errors in the first game and 40 in spaceinvaders104. Incase it is effecting it heres some details package path : C:/JAVA/spaceinvaders/ (then /org and /sprites) current path == C:/JAVA/spaceinvaders/ command im using : >javac org/newdawn/spaceinvaders/Game.java I was using javac at the base of the package, i was also using jcreator. By the way, thanks for your help! Also, nice site, its the only one iv been sent to thats not entirely applet based Added i got it to compile with this : in the director of game.java javac *.java but now i cant get it to run , i try java game.class but it says undefined class game()
|
|
|
|
|
oNyx
|
 |
«
Reply #11 - Posted
2006-01-24 14:34:09 » |
|
Well, its "Game" and not "game".
Eventually your java installation is broken. My bro's install was b0rked once and it behaved very weird. So, maybe its a good idea to uninstall java and install it again. Set up the path stuff (<win>+<break> -> advanced (or something) -> environment variables... add the jdk's bin path to path... eg it could look like this: C:\Programme\GTK2-Runtime\lib;D:\java\jdk1.5.0_05\bin) and then try it again.
|
|
|
|
tusaki
Junior Member  
In a mad world only the mad are sane.
|
 |
«
Reply #12 - Posted
2006-01-24 17:33:56 » |
|
Erh. Why not install an editor like eclipse? I haven't manually compiled a java program in years! And I shudder at what I had to go through back in those days... The difference is night and day.
|
|
|
|
|
kevglass
|
 |
«
Reply #13 - Posted
2006-01-24 17:38:01 » |
|
Its pretty good to get compilation to work at the command line as a start - always nice to begin with the basics and build up.
Kev
|
|
|
|
oNyx
|
 |
«
Reply #14 - Posted
2006-01-24 18:04:28 » |
|
This command line stuff is also the easiest way to reproduce.
X:\foo\spaceinvaders.zip\spaceinvaders>dir/b org sprites
X:\foo\spaceinvaders.zip\spaceinvaders>javac org/newdawn/spaceinvaders/Game.java Note: org/newdawn/spaceinvaders/Game.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details.
X:\foo\spaceinvaders.zip\spaceinvaders>java org.newdawn.spaceinvaders.Game
C'mon... its easy.
|
|
|
|
comanighttrain
Senior Newbie 
|
 |
«
Reply #15 - Posted
2006-01-24 19:04:31 » |
|
Im doing exactly as you said man...seriously.
My Path : > dir C:\JAVA\spaceinvaders
>dir/b org sprites
> javac org/newdawn/spaceinvaders/Game.java
24 compile errors
I just reinstalled java SDK with the newest update and its making no difference. Is it something iv screwed up or is my system actually screwed?
|
|
|
|
|
kevglass
|
 |
«
Reply #16 - Posted
2006-01-24 19:38:47 » |
|
Could you list the errors, it might help.
Kev
|
|
|
|
comanighttrain
Senior Newbie 
|
 |
«
Reply #17 - Posted
2006-01-24 20:19:58 » |
|
All the errors are
cannot find symbol Class : Entity/ShotEntity/AlienEntity Location : org.newdawn.spaceinvaders.Game
Heres the exact dump from the console : C:\JAVA\spaceinvaders>dir/b org sprites
C:\JAVA\spaceinvaders>javac org/newdawn/spaceinvaders/Game.java org/newdawn/spaceinvaders/Game.java:42: cannot find symbol symbol : class Entity location: class org.newdawn.spaceinvaders.Game private Entity ship; ^ org/newdawn/spaceinvaders/Game.java:170: cannot find symbol symbol : class Entity location: class org.newdawn.spaceinvaders.Game public void removeEntity(Entity entity) { ^ org/newdawn/spaceinvaders/Game.java:141: cannot find symbol symbol : class ShipEntity location: class org.newdawn.spaceinvaders.Game ship = new ShipEntity(this,"sprites/ship.gif",370,550); ^ org/newdawn/spaceinvaders/Game.java:148: cannot find symbol symbol : class Entity location: class org.newdawn.spaceinvaders.Game Entity alien = new AlienEntity(this,"sprites/ali en.gif",100+(x*50),(50)+row*30); ^ org/newdawn/spaceinvaders/Game.java:148: cannot find symbol symbol : class AlienEntity location: class org.newdawn.spaceinvaders.Game Entity alien = new AlienEntity(this,"sprites/ali en.gif",100+(x*50),(50)+row*30); ^ org/newdawn/spaceinvaders/Game.java:205: cannot find symbol symbol : class Entity location: class org.newdawn.spaceinvaders.Game Entity entity = (Entity) entities.get(i); ^ org/newdawn/spaceinvaders/Game.java:205: cannot find symbol symbol : class Entity location: class org.newdawn.spaceinvaders.Game Entity entity = (Entity) entities.get(i); ^ org/newdawn/spaceinvaders/Game.java:207: cannot find symbol symbol : class AlienEntity location: class org.newdawn.spaceinvaders.Game if (entity instanceof AlienEntity) { ^ org/newdawn/spaceinvaders/Game.java:227: cannot find symbol symbol : class ShotEntity location: class org.newdawn.spaceinvaders.Game ShotEntity shot = new ShotEntity(this,"sprites/shot.gif",ship.ge tX()+10,ship.getY()-30); ^ org/newdawn/spaceinvaders/Game.java:227: cannot find symbol symbol : class ShotEntity location: class org.newdawn.spaceinvaders.Game ShotEntity shot = new ShotEntity(this,"sprites/shot.gif",ship.ge tX()+10,ship.getY()-30); ^ org/newdawn/spaceinvaders/Game.java:227: operator + cannot be applied to Entity. getX,int ShotEntity shot = new ShotEntity(this,"sprites/shot.gif",ship.ge tX()+10,ship.getY()-30);
^ org/newdawn/spaceinvaders/Game.java:262: cannot find symbol symbol : class Entity location: class org.newdawn.spaceinvaders.Game Entity entity = (Entity) entities.get(i) ; ^ org/newdawn/spaceinvaders/Game.java:262: cannot find symbol symbol : class Entity location: class org.newdawn.spaceinvaders.Game Entity entity = (Entity) entities.get(i) ; ^ org/newdawn/spaceinvaders/Game.java:270: cannot find symbol symbol : class Entity location: class org.newdawn.spaceinvaders.Game Entity entity = (Entity) entities.get(i); ^ org/newdawn/spaceinvaders/Game.java:270: cannot find symbol symbol : class Entity location: class org.newdawn.spaceinvaders.Game Entity entity = (Entity) entities.get(i); ^ org/newdawn/spaceinvaders/Game.java:280: cannot find symbol symbol : class Entity location: class org.newdawn.spaceinvaders.Game Entity me = (Entity) entities.get(p); ^ org/newdawn/spaceinvaders/Game.java:280: cannot find symbol symbol : class Entity location: class org.newdawn.spaceinvaders.Game Entity me = (Entity) entities.get(p); ^ org/newdawn/spaceinvaders/Game.java:281: cannot find symbol symbol : class Entity location: class org.newdawn.spaceinvaders.Game Entity him = (Entity) entities.get(s); ^ org/newdawn/spaceinvaders/Game.java:281: cannot find symbol symbol : class Entity location: class org.newdawn.spaceinvaders.Game Entity him = (Entity) entities.get(s); ^ org/newdawn/spaceinvaders/Game.java:299: cannot find symbol symbol : class Entity location: class org.newdawn.spaceinvaders.Game Entity entity = (Entity) entities.get(i) ; ^ org/newdawn/spaceinvaders/Game.java:299: cannot find symbol symbol : class Entity location: class org.newdawn.spaceinvaders.Game Entity entity = (Entity) entities.get(i) ; ^ Note: org/newdawn/spaceinvaders/Game.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 21 errors
|
|
|
|
|
oNyx
|
 |
«
Reply #18 - Posted
2006-01-24 21:19:18 » |
|
Well, your java installation is broken, because the current directory isnt in the classpath (its in the classpath by default since 1.3 iirc).
Try "javac -cp . org/newdawn/spaceinvaders/Game.java" instead.
|
|
|
|
comanighttrain
Senior Newbie 
|
 |
«
Reply #19 - Posted
2006-01-24 21:26:04 » |
|
ok...that worked...
i try to java the Game class file and i get
C:\JAVA\spaceinvaders>java org/newdawn/spaceinvaders/Game.class Exception in thread "main" java.lang.NoClassDefFoundError: org/newdawn/spaceinva ders/Game/class
How do i go about fixing my java installation?
|
|
|
|
|
oNyx
|
 |
«
Reply #20 - Posted
2006-01-24 21:35:50 » |
|
Omit that ".class" bit at the end.
>How do i go about fixing my java installation?
Uninstalling all java stuff and reinstalling it should fix it.
|
|
|
|
comanighttrain
Senior Newbie 
|
 |
«
Reply #21 - Posted
2006-01-24 21:39:46 » |
|
i have uninstalled and reinstalled it twice...no diff...maybe try redownloading it?
|
|
|
|
|
tusaki
Junior Member  
In a mad world only the mad are sane.
|
 |
«
Reply #22 - Posted
2006-01-24 21:50:20 » |
|
don't do this 1
| C:\JAVA\spaceinvaders>java org/newdawn/spaceinvaders/Game.class |
but this 1
| C:\JAVA\spaceinvaders>java org.newdawn.spaceinvaders.Game |
|
|
|
|
|
jbanes
|
 |
«
Reply #23 - Posted
2006-01-24 21:51:02 » |
|
i have uninstalled and reinstalled it twice...no diff...maybe try redownloading it? 1. Right click on "My Computer". 2. Click on "Properties" 3. Select the "Advanced" tab 4. Click on "Environment Variables" 5. Select "Classpath" from the list and hit "Delete" (You may have to do this for both lists.) Restart any open command-line windows you have and you should be good to go.
|
|
|
|
comanighttrain
Senior Newbie 
|
 |
«
Reply #24 - Posted
2006-01-25 01:02:36 » |
|
i have uninstalled and reinstalled it twice...no diff...maybe try redownloading it? 1. Right click on "My Computer". 2. Click on "Properties" 3. Select the "Advanced" tab 4. Click on "Environment Variables" 5. Select "Classpath" from the list and hit "Delete" (You may have to do this for both lists.) Restart any open command-line windows you have and you should be good to go. Dave <3 jbanes 4 ever No seriously, thats done the trick, Thanks alot. Thanks a lot to everyone for giving me your time and patience:), hopefully one day i can help someone out too!
|
|
|
|
|
|