Java-Gaming.org Java4K winners: [ by our judges | by the community ]         
Featured games (67)
games approved by the League of Dukes
Games in Showcase (∞)
games submitted by our members



News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1] 2
  Print  
  Space Invaders Tutorial Game  (Read 5032 times)
0 Members and 3 Guests are viewing this topic.
Offline 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.jnlp

Or for the web start fearing

http://www.cokeandcode.com/spaceinvaders/si101.jar

Obviously 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.

Offline blahblahblahh

JGO Kernel
*****

Posts: 4575


http://t-machine.org


« Reply #1 on: 2004-04-11 15:28:41 »

Quote
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...
Offline 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

http://www.untoldevils.com  
An RPG like every other, except this one is made by me
Games published by our own members! Go get 'em!
Offline 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  Grin

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

Offline 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 Wink

Kev

Offline oNyx

JGO Kernel
*****

Posts: 2943
Medals: 5


pixels! :x


« Reply #5 on: 2004-04-11 16:01:35 »

Nice Smiley

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)

弾幕 ☆ @mahonnaiseblog
Offline 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 Wink

Just commenting the source in preperation for writing the tutorial

Kev

Offline oNyx

JGO Kernel
*****

Posts: 2943
Medals: 5


pixels! :x


« Reply #7 on: 2004-04-11 16:38:20 »

>Should fixed the Onyx Bugs Wink

Affirmative! Grin

Something odd (poke poke)... if I don't move there is autofire and if I move there isn't autofire. Hm Smiley

弾幕 ☆ @mahonnaiseblog
Offline 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) Smiley

Kev

Offline kevglass
« League of Dukes »

JGO Kernel
*****

Posts: 5214
Medals: 49


Mentally unstable, best avoided.


« Reply #9 on: 2004-04-11 17:01:36 »

And finally, heres the source, all perty:

http://www.cokeandcode.com/spaceinvaders/spaceinvaders.zip

I'll write a tutorial around it if anyone wants, assuming I get up tomorrow.

Kev

Games published by our own members! Go get 'em!
Offline 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!
Offline 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 Smiley

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 (Roll Eyes) 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 Wink

弾幕 ☆ @mahonnaiseblog
Offline blahblahblahh

JGO Kernel
*****

Posts: 4575


http://t-machine.org


« Reply #12 on: 2004-04-11 19:32:23 »

Quote

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 Wink


So...you'd be happy to see them used in a game ? Smiley

malloc will be first against the wall when the revolution comes...
Offline blahblahblahh

JGO Kernel
*****

Posts: 4575


http://t-machine.org


« Reply #13 on: 2004-04-11 19:36:51 »

Quote

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 Sad ).

[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 Sad]

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...
Offline oNyx

JGO Kernel
*****

Posts: 2943
Medals: 5


pixels! :x


« Reply #14 on: 2004-04-11 20:00:46 »

Quote
So...you'd be happy to see them used in a game ? Smiley


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* Smiley

弾幕 ☆ @mahonnaiseblog
Offline kevglass
« League of Dukes »

JGO Kernel
*****

Posts: 5214
Medals: 49


Mentally unstable, best avoided.


« Reply #15 on: 2004-04-12 03:20:52 »

Quote

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 Smiley

Kev

Offline blahblahblahh

JGO Kernel
*****

Posts: 4575


http://t-machine.org


« Reply #16 on: 2004-04-12 04:27:02 »

Quote


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? Grin

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...
Offline 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 Wink 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.html

Kev

EDIT: Apologies, its turned into a bit of an epic.

Offline 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 Wink).

malloc will be first against the wall when the revolution comes...
Offline Chilly_D

JGO n00b
*

Posts: 4


Java games rock!


« Reply #19 on: 2004-04-12 14:26:41 »

Grin

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
Offline 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 Wink)

Kev

Offline oNyx

JGO Kernel
*****

Posts: 2943
Medals: 5


pixels! :x


« Reply #21 on: 2004-04-12 17:26:39 »

Quote
Why, I hadn't thought of that! Good idea...why don't you? Grin


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) Smiley

Quote
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 Smiley

Animated:

弾幕 ☆ @mahonnaiseblog
Offline 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

Offline 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/
Offline 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?

Sacramento Volleyball
"Whitty phrase goes here."
Offline 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... Smiley Nice job!

Kev

Offline 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 Smiley )

Offline 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

Offline Chilly_D

JGO n00b
*

Posts: 4


Java games rock!


« Reply #28 on: 2004-04-14 14:29:35 »

Hello  Smiley

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
Offline 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.

Pages: [1] 2
  Print  
 
 
Jump to:  


Add your game by posting it in the showcase section.

The first screenshot will be displayed as a thumbnail.

obsidian_golem 2012-05-23 10:14:50

Danny02 2012-05-21 17:10:34

Danny02 2012-05-21 17:07:10

Danny02 2012-05-21 16:56:12

davedes 2012-05-21 13:59:23

obsidian_golem 2012-05-20 20:28:41

darkjava55 2012-05-12 16:14:40

Ultroman 2012-05-12 09:36:05

Ultroman 2012-05-11 22:49:53

Ultroman 2012-05-11 22:20:01
Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.286 seconds with 19 queries.