kevglass
« League of Dukes » JGO Kernel      Posts: 5214 Medals: 49
Mentally unstable, best avoided.
|
 |
«
on:
2004-04-11 15:15:34 » |
|
Spent an hour tonight putting this together: http://www.cokeandcode.com/spaceinvaders/si101.jnlpOr for the web start fearing http://www.cokeandcode.com/spaceinvaders/si101.jarObviously its not a full game but I was going to use it to write a tutorial and hoped I could solicit feedback on OS compatibility and whether it covers enough for the super beginner? At the moment it should cover: * Accelerated Mode Graphics * Simple OO Concepts in relations to games * Game Loop * Input control * Timing * Game Logic / AI EDIT: * Brute force collision detection All at very simple levels. Comments welcome, tutorial should be out tomorrow assuming no-one mentions a reason not to. Kev EDIT2: Controls, cursors for left/right movement, space to shoot, ESC to quit.
|
|
|
|
blahblahblahh
JGO Kernel      Posts: 4575
http://t-machine.org
|
 |
«
Reply #1 on:
2004-04-11 15:28:41 » |
|
Spent an hour tonight putting this together: * Input control
A bit screwed... Holding down left I often had the ship go what looked like "two steps left, one step right, 2 left, 1 right, ..." etc. It moved left, but slowly, and kept shaking as though it had caffeine-withdrawal symptoms. Sometimes I was faster than the aliens, sometimes slower, sometimes the same speed - and it seemed I sped up and slowed down randomly, even when I was merely moving across the screen and firing but not hitting anything. Also, when the game restarted (I killed all the nasties) I hit space to restart but after the restart my ship would ONLY go left, no matter if I tapped keys, held down keys, etc. There were some "interesting" layout patterns with the aliens too - some of them were slightly overlapping, as if they'd been jittered out of a regular grid ? Apart from that, worked fine. 1.4.2_04 linux.
|
malloc will be first against the wall when the revolution comes...
|
|
|
Seekely
JGO n00b  Posts: 49
I am java
|
 |
«
Reply #2 on:
2004-04-11 15:31:09 » |
|
Nice idea, worked well for me on Windows 2000 1.5b
Only complaint was I lost keyboard focus, and wasn't able to get it back
|
|
|
|
Games published by our own members! Go get 'em!
|
|
kevglass
« League of Dukes » JGO Kernel      Posts: 5214 Medals: 49
Mentally unstable, best avoided.
|
 |
«
Reply #3 on:
2004-04-11 15:31:24 » |
|
Coo, that'll teach me not to test all multi-platform before putting it out to the public  Most of those problems "could" be explained by the lack of a high-res timer on windows (but of course you're on linux so I'm baffled). As normal, its a "works perfectly" here case. Time to boot up the linux box. Kev
|
|
|
|
kevglass
« League of Dukes » JGO Kernel      Posts: 5214 Medals: 49
Mentally unstable, best avoided.
|
 |
«
Reply #4 on:
2004-04-11 15:43:10 » |
|
Version 2 uploaded, might resolve some issues. Heh, might cause some new ones  Kev
|
|
|
|
oNyx
JGO Kernel      Posts: 2943 Medals: 5
pixels! :x
|
 |
«
Reply #5 on:
2004-04-11 16:01:35 » |
|
Nice  Found two minior thingies: -the bullet offset is slightly off (looks like you forgot the width of the bullet) -and a slight input glitch (reproducable) 1. shoot em all exept one 2. move left or right (holding) 3. shoot the last one 4. release direction key 5. press space to continue Then your ship moves into that pressed direction until you press that key again (and thus triggering a release event)
|
|
|
|
kevglass
« League of Dukes » JGO Kernel      Posts: 5214 Medals: 49
Mentally unstable, best avoided.
|
 |
«
Reply #6 on:
2004-04-11 16:08:23 » |
|
Version 3, just uploaded. Should fixed the Onyx Bugs  Just commenting the source in preperation for writing the tutorial Kev
|
|
|
|
oNyx
JGO Kernel      Posts: 2943 Medals: 5
pixels! :x
|
 |
«
Reply #7 on:
2004-04-11 16:38:20 » |
|
>Should fixed the Onyx Bugs  Affirmative!  Something odd (poke poke)... if I don't move there is autofire and if I move there isn't autofire. Hm 
|
|
|
|
kevglass
« League of Dukes » JGO Kernel      Posts: 5214 Medals: 49
Mentally unstable, best avoided.
|
 |
«
Reply #8 on:
2004-04-11 16:42:52 » |
|
Ping! And as if by magic, version 4 appeared (which supported auto-fire when moving)  Kev
|
|
|
|
|
|
Games published by our own members! Go get 'em!
|
|
nonnus29
JGO Ninja    Posts: 687
Giving Java a second chance after ludumdare fiasco
|
 |
«
Reply #10 on:
2004-04-11 18:17:14 » |
|
Yes, write a tutorial. This is exactly the type of intro tutorial thats needed for java; j2d, bufferstrategies, input handling, oop for games, a game as an application etc....
You might add a fps counter so people can see the 100+ frames per sec this surely runs at ---> help dispell that unfortunate lack of performance myth!
Good job!
|
|
|
|
|
oNyx
JGO Kernel      Posts: 2943 Medals: 5
pixels! :x
|
 |
«
Reply #11 on:
2004-04-11 19:26:54 » |
|
Yep, works as it should. Good work Kevin  And about the tut... it would be (could be) a nice idea to add some "homework" at the end, like adding a score counter, levels, lives, whatsoever. Just mention some things, wich the readers should try to implement by themselfes. If you ever make a second part... eventually about mouse handling, slicing images and dunno. You could use these images, I did a year ago:  (Frame 1 is based on a scan from a very very very old [~60yrs+] medicine book and the following frames are just edits of the previous frame.)  (Kinda from vcop (  ) rescaled, bitmask, lots of cleanup on pixel level - really a major PITA. Took about 3 hours. Doh.) Well, they look kinda nice and were alot of work... and I thought it would have been a waste if I just let em rot on my hdd 
|
|
|
|
blahblahblahh
JGO Kernel      Posts: 4575
http://t-machine.org
|
 |
«
Reply #12 on:
2004-04-11 19:32:23 » |
|
Well, they look kinda nice and were alot of work... and I thought it would have been a waste if I just let em rot on my hdd  So...you'd be happy to see them used in a game ? 
|
malloc will be first against the wall when the revolution comes...
|
|
|
blahblahblahh
JGO Kernel      Posts: 4575
http://t-machine.org
|
 |
«
Reply #13 on:
2004-04-11 19:36:51 » |
|
I'll write a tutorial around it if anyone wants, assuming I get up tomorrow.
And, once I've seen the tutorial, I might even feel it's sufficiently easy to finally use it as a launch pad for a full example of adding NIO networking to a game, in a non-trivial way (unfortunately, I'm working throughout easter, and got ill over the weekend, so practially no free time for me to do such worthy things  ). [still hoping to get around to finishing my NIO articles with full source to a networked multi-player tetris. But, right now, I'm so damned sick of NIO networking, having been nose-to-monitor in it for a week, that I don't think I could face it right now  ] PS: I saw some things this week that indicate Sun *may* have fixed the performance bug in gathering writes. More news when I have a final answer (or...someone could go through the old Networking topics, dig out my testcase for the performance bug, and check it on the current VM's)
|
malloc will be first against the wall when the revolution comes...
|
|
|
oNyx
JGO Kernel      Posts: 2943 Medals: 5
pixels! :x
|
 |
«
Reply #14 on:
2004-04-11 20:00:46 » |
|
So...you'd be happy to see them used in a game ?  I'm wondering if that is one of those indirect "then make a game goddamnit" invitations. I know you want to get more submissions for that external games page. You'll get one from me pretty soonish *poke* 
|
|
|
|
kevglass
« League of Dukes » JGO Kernel      Posts: 5214 Medals: 49
Mentally unstable, best avoided.
|
 |
«
Reply #15 on:
2004-04-12 03:20:52 » |
|
You might add a fps counter so people can see the 100+ frames per sec this surely runs at ---> help dispell that unfortunate lack of performance myth!
Was going to leave this one as homework task, so the reader gets a nice surprise  Kev
|
|
|
|
blahblahblahh
JGO Kernel      Posts: 4575
http://t-machine.org
|
 |
«
Reply #16 on:
2004-04-12 04:27:02 » |
|
I'm wondering if that is one of those indirect "then make a game goddamnit" invitations.
Why, I hadn't thought of that! Good idea...why don't you?  Actually, though, I was just thinking that the skull could work quite well in quite a lot of games, could be worked into a player-death animation. Although I haven't seen it animated yet, of course.
|
malloc will be first against the wall when the revolution comes...
|
|
|
kevglass
« League of Dukes » JGO Kernel      Posts: 5214 Medals: 49
Mentally unstable, best avoided.
|
 |
«
Reply #17 on:
2004-04-12 13:46:06 » |
|
Having spent the day getting my new pond set up  I finally managed to secure a couple of hours this evening to type this up. First draft of the tutorial is here: http://www.cokeandcode.com/info/tut2d.htmlKev EDIT: Apologies, its turned into a bit of an epic.
|
|
|
|
blahblahblahh
JGO Kernel      Posts: 4575
http://t-machine.org
|
 |
«
Reply #18 on:
2004-04-12 14:15:27 » |
|
Suggestion: "pretty-print" the source into syntax-highlighted HTML. If your IDE doesn't do this, there's a JEdit plugin that does and I can export the sources for you. Then post each .java file as an html page. This makes reading the source whilst reading the tutorial much easier for a lot of people (especially those without good IDE's  ).
|
malloc will be first against the wall when the revolution comes...
|
|
|
Chilly_D
JGO n00b  Posts: 4
Java games rock!
|
 |
«
Reply #19 on:
2004-04-12 14:26:41 » |
|
 Hello - I am new to this forum Thank you for producing such an excellent tutorial - I have been looking for just such a tutorial to explain the basics of coding 2D games using Java and this has given me everything I need to get started Consider me to be a very, very happy bunny indeed
|
|
|
|
|
kevglass
« League of Dukes » JGO Kernel      Posts: 5214 Medals: 49
Mentally unstable, best avoided.
|
 |
«
Reply #20 on:
2004-04-12 14:35:30 » |
|
@blahblahblah Thanks for William Dennis (great chap!) I now have code context highlighted via a beautiful php script (with a few compatibility hacks from me  ) Kev
|
|
|
|
oNyx
JGO Kernel      Posts: 2943 Medals: 5
pixels! :x
|
 |
«
Reply #21 on:
2004-04-12 17:26:39 » |
|
Why, I hadn't thought of that! Good idea...why don't you?  Heh. One is at about 90% (TinyRivers) and two others at about 50%. I'm doin my best finishing em asap (I really need skill demonstrations right now)  Actually, though, I was just thinking that the skull could work quite well in quite a lot of games, could be worked into a player-death animation. Although I haven't seen it animated yet, of course. Yea well... it won't match (style wise) into anything, wich is in my pipeline. But, y'know, I thought it's a waste to let it rot  Animated: 
|
|
|
|
kevglass
« League of Dukes » JGO Kernel      Posts: 5214 Medals: 49
Mentally unstable, best avoided.
|
 |
«
Reply #22 on:
2004-04-13 01:20:47 » |
|
I finished reading through, tried to sort most of the grammar/speeeeeling out.
I'm going to add a "Further Reading" section but so far I can only think of:
* <shameless_plug>My webstart guide</shameless_plug> * The Full Screen Exclusive Mode Tutorial * The GAGE library (Timer especially)
Anything else?
Kev
|
|
|
|
monkeyget
JGO n00b  Posts: 37
|
 |
«
Reply #23 on:
2004-04-13 08:03:09 » |
|
I messed up with the code and the game to practice a bit, now the game is a kind of side scroller with enemies coming from the upper part of the screen and going down. I'v added stuff like enemies which shoot back at you, dust particles (so we feel like moving), ship moving in x and y with inertia,... my version is available here: http://membres.lycos.fr/nolagrulez/java/si%20monkeyget's%20build.jar(don't forget to use up/down keys) \o/ kevglass \o/
|
|
|
|
|
SpuTTer
Full Member   Posts: 246 Medals: 1
Lazy Middle Class Intellectual
|
 |
«
Reply #24 on:
2004-04-13 10:49:06 » |
|
Ack, but you didnt webstart it?
|
|
|
|
kevglass
« League of Dukes » JGO Kernel      Posts: 5214 Medals: 49
Mentally unstable, best avoided.
|
 |
«
Reply #25 on:
2004-04-13 10:52:33 » |
|
Webstart aside, fair play, thats ace...  Nice job! Kev
|
|
|
|
swpalmer
JGO Kernel      Posts: 3438 Medals: 4
Where's the Kaboom?
|
 |
«
Reply #26 on:
2004-04-13 11:11:20 » |
|
Just thought I would report that it works fine on OS X 10.3.3. Very nice tutorial. You should link it from the Wiki (you know that thing that nobody uses  )
|
|
|
|
kevglass
« League of Dukes » JGO Kernel      Posts: 5214 Medals: 49
Mentally unstable, best avoided.
|
 |
«
Reply #27 on:
2004-04-13 11:17:28 » |
|
As he said, it shall be done! Ping!
Kev
|
|
|
|
Chilly_D
JGO n00b  Posts: 4
Java games rock!
|
 |
«
Reply #28 on:
2004-04-14 14:29:35 » |
|
Hello  I have been studying the code for the tutorial using JBuilder X Foundation - when I run it, the following message appears "Can't find ref: sprites/ship.gif" The folder structure within the JB project directory is f - SpaceInvader --- f - scr .........contains the java source files --- f - classes ...contains the compiled java class files --- f - sprites ....contains the three gif files --- f - bak ........contains the JB backup files I have tried to learn about ClassLoader etc and I have a rough idea of what it is designed to do but I am not sure about how its functionality relates to this problem as I suspect it is something to do with the way the files are stored as indicated above I understand that this isn't a forum for JB problems, but could any of you explain to me why the code isn't working in JB Thank you
|
|
|
|
|
kevglass
« League of Dukes » JGO Kernel      Posts: 5214 Medals: 49
Mentally unstable, best avoided.
|
 |
«
Reply #29 on:
2004-04-14 15:34:43 » |
|
I was a little worried about this, hence the blag in the tutorial.
Your "classpath" needs to include your SpaceInvader directory. How you do this in JBuilder, god only knows.. but I suspect they'll be a configuration option on whereever you configure which class is executed..
Kev
PS. I might revisit this bit slightly.
|
|
|
|
|