Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Space invader game

 
Ranch Hand
Posts: 954
4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to make a space invader game for self practice using TDD approach. I have written some points and did some implementation. Please suggest:

Goal: We should protect invasion from the invaders by shooting them

Some To do list:

1) Should kill the invaders using laser for protecting invasion
2) Should move laser sideways to protect it from the invaders attack
3) Should get new laser if available when destroyed by invaders
4) Should be game over when all the lasers destroyed by invaders
5) Should add 10 points into the total score whenever any invader killed


I worked on points 1 and 3. So my code is:






 
Tushar Goel
Ranch Hand
Posts: 954
4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Correction in GameTest class. Method name "isShotHitInvader_should_return_true_if_hit" instead "isMissileHitInvader_should_return_true_if_hit". Now other classes are:










 
Sheriff
Posts: 17665
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Some of your code doesn't make sense to me. Why would a laser shoot a game? That's what I read when I see
 
Tushar Goel
Ranch Hand
Posts: 954
4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Junilu, i thought laser doesn't know whether the shot has been hit to invaders or not. It just shoot. Its game responsibility to check if it hits the invaders or not.

What else do you think is wrong?
 
Junilu Lacar
Sheriff
Posts: 17665
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tushar,

This has the potential to turn into another very long thread, which honestly is a direction I'm not inclined to go right now. Let me just say that it seems like you have gone into the deep end of your detailed requirements without having a clear high level, big picture yet. Things like this need to be refined in small, incremental steps. By starting with a statement like "I want to write a Space Invaders Game in Java" then suddenly going to "Should kill the invaders using laser for protecting invasion" is skipping many of those intermediate refinements. It's like saying "I want to plan a trip to Hawaii" then you suddenly say "I need a bucket to put pretty shells in." A casual observer will likely say, "WTH? How did you get from wanting to plan a trip to Hawaii to collecting shells in a bucket all of a sudden?!"

Perhaps you should choose simpler problems first while you try to build up your TDD skills. A full-blown game simulation seems like overreach right now. You may be familiar with the phrase "Your eyes are bigger than your stomach" or something like that?
 
Tushar Goel
Ranch Hand
Posts: 954
4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Junilu, you are right. Right now, i may not have desired skills to create complex programme. I will continue on this when i get desired skills.

I need to focus on small things now. Any suggestion?
 
Junilu Lacar
Sheriff
Posts: 17665
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't worry about it, all that will come with practice. There are lots of homework in the Beginner forum that you can try your hand at. It's also interesting to compare what you come up with when you TDD some of these problems vs the solutions that the OPs post. If you do manage to come up with a solution for a homework problem though, remember not to give too much away to the OP so they can still do it themselves.
 
Junilu Lacar
Sheriff
Posts: 17665
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tushar, check out this thread to get some ideas: https://coderanch.com/t/628047/patterns/Parking-Lot-Design
 
Tushar Goel
Ranch Hand
Posts: 954
4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah thanks.. It gives me some idea about to clearly representing the todo list and other's things.
 
reply
    Bookmark Topic Watch Topic
  • New Topic