This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Space Invaders  RSS feed

 
Alaric Mustoe
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok so during the break I had to code some stuff for my project and I need help. This is the main class
This is the enemy class
and this is the entity class

So anyways I am stumped it is probably something easy but I can't see it.
 
K. Tsang
Bartender
Posts: 3648
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow space invaders fun fun!

So what you stumped on?
 
Alaric Mustoe
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It has to do with the constructor within the Enemy class my array Enemies are the only things not working so ya.
 
K. Tsang
Bartender
Posts: 3648
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see, your Enemy class constructor has 3 parameters. But when you use it in JForumAnimationJunk class (line 62), you pass in only 1 parm (the image), when it expects a int, int, String.

 
Alaric Mustoe
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok now I have the problem of getting the enemies to move with this code I can't fix the errors regarding the move Saucer and move Enemies method.
 
Matt Cartwright
Ranch Hand
Posts: 152
Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hmm, the saucer works on my machine


maybe you should get some IDE and structure your code???
HTH
Matt
 
Alaric Mustoe
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you misunderstand but thanks for the code I tried it out i would like the saucer to move without human input so move automatically.

Thanks again
 
Dave Tolls
Rancher
Posts: 2911
35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where do you actually move the saucer?
I can't see that (offhand) in the actionPerformed.
 
Matt Cartwright
Ranch Hand
Posts: 152
Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Dave
that is correct,


is called by the timer and in the Sprite's move() method we do the boundary checking after adding the deltas from key events..

@Alaric
there were key events (q &e) defined for the saucer, that's what I implemented....
just take it as an example and use it for your laser cannon.
The saucer isn't visible in the beginning of the game and scrolls from left (off) to right off.
So the minX for it would need to be adjusted for that.
Why not have a counter incremented in in actionPerformed() that triggers the appearance of the saucer?
I think you got the idea...

HTH
Matt
 
Alaric Mustoe
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok so I have moving enemies now I have the question of shooting using keybinding.
help?
shot

 
Alaric Mustoe
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok so then I need help with collision detection for my barriers and enemies along with the player can you help?
this is the barrier
enemy
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!