Author Topic: My Helicopter Game  (Read 11242 times)

0 Members and 1 Guest are viewing this topic.

Offline Tgooseman

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 17
  • Rating: +1/-0
    • View Profile
My Helicopter Game
« on: April 23, 2011, 03:49:30 pm »
So I am making a helicopter-like game using Axe, and since it is my first game I some help!  I am currently stuck making it scroll sideways. Would this involve using two buffers? Maybe like drawing the bricks there and shifting pixels left? This would be my guess (although I could be way wrong :D )!

For those of you that don't know what the helicopter game is, it is the game where you move your helicopter to avoid the incoming bricks.

Offline Fast Crash

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 192
  • Rating: +45/-7
  • Virus of tomorrow
    • View Profile
Re: My Helicopter Game
« Reply #1 on: April 23, 2011, 04:02:26 pm »
You mean a tunnel game ?
This is simple actually, you just have to scroll the screen to the left ( using Horizontal - ) and make bricks appear at a random Y position on the right of the screen.

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: My Helicopter Game
« Reply #2 on: April 23, 2011, 04:04:11 pm »
You mean a tunnel game ?
This is simple actually, you just have to scroll the screen to the left ( using Horizontal - ) and make bricks appear at a random Y position on the right of the screen.

No, he really means a helicopter game, in a copter game there's gravity you have to keep press UP to go UP or gravity will kill you. But the engine is pretty much the same.

Offline ingalls

  • LV3 Member (Next: 100)
  • ***
  • Posts: 49
  • Rating: +4/-0
  • :)
    • View Profile
Re: My Helicopter Game
« Reply #3 on: April 23, 2011, 04:05:37 pm »
I used two variables for my game nFighter (in Lua) offsetX and offsetY if the user used the up arrow, the code would be
Code: [Select]
offsetY = offsetY - whateverthepixeloffsethere then that value is added onto the background image making it look like the helicopter goes up.

The game your talking about is pretty fun, if diffucult. I look forward to seeing what you come up with!

Cheers
Ingalls
« Last Edit: April 23, 2011, 04:06:45 pm by ingalls »

Offline Tgooseman

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 17
  • Rating: +1/-0
    • View Profile
Re: My Helicopter Game
« Reply #4 on: April 23, 2011, 05:16:00 pm »
Alright, thanks for the suggestions.  The reason I thought I would need two buffers is because when I update the screen for my Helicopter sprite, I use ClrDraw, which would end up wiping out the brick moving across the screen.  Any ideas to counter this?

Offline Fast Crash

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 192
  • Rating: +45/-7
  • Virus of tomorrow
    • View Profile
Re: My Helicopter Game
« Reply #5 on: April 23, 2011, 05:22:03 pm »
Pt-Change(X,Y,[yoursprite]) will erase the sprite ( if it is at the same position )

Offline ingalls

  • LV3 Member (Next: 100)
  • ***
  • Posts: 49
  • Rating: +4/-0
  • :)
    • View Profile
Re: My Helicopter Game
« Reply #6 on: April 23, 2011, 05:29:21 pm »
If you don't min the background of the game moving up and down the position of the helicopter never has to change, you want the helecopter to be in the center of the Y plane and in the first quarter of the X plane based on the versions of the game that I have see. So on a 10x10 grid you would want to draw the helicopter at (x,y) (2.5,5) The helicopter would then be redrawn at that set of coordinates every time.

For the background you would draw out the level and then have an Yoffset value that can be added on, is drawRect(1,1+offsetY)
That way if the user goes up then a negative y value will be added on, making the background go down, and giving the illusion that the helicopter went up. The opposite would be true for the user pressing the down key.

If you want to see the method I have just described in action and you are comfortable looking at the code of a porgramming language that you don't necessarily know, have a look at my nFighter code. All of the background objects have both X and Y offset values so the crosshairs appear to move when in face only the background does.

Cheers
Ingalls

Offline ingalls

  • LV3 Member (Next: 100)
  • ***
  • Posts: 49
  • Rating: +4/-0
  • :)
    • View Profile
Re: My Helicopter Game
« Reply #7 on: April 23, 2011, 05:31:39 pm »
The idea Fast Crash suggested above would be even better. It would allow you to keep the map stationary and only move the helecopter... That's basically my suggestion except in reverse, move the object instead of the background

. I haven't programmed in Axe before so I'm not sure of the power of the language...


Offline Michael_Lee

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1019
  • Rating: +124/-9
    • View Profile
Re: My Helicopter Game
« Reply #8 on: April 23, 2011, 05:35:36 pm »
Axe can easily handle both, although using Pt-Change would be much more easier to implement (and would probably run faster, at the cost of not being able to move around much).
My website: Currently boring.

Projects:
Axe Interpreter
   > Core: Done
   > Memory: Need write code to add constants.
   > Graphics: Rewritten.  Needs to integrate sprites with constants.
   > IO: GetKey done.  Need to add mostly homescreen IO stuff.
Croquette:
   > Stomping bugs
   > Internet version: On hold until I can make my website less boring/broken.

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: My Helicopter Game
« Reply #9 on: April 24, 2011, 05:15:09 am »
I have a problem with making a tunnel game/helicoter game too...

Code: [Select]
...
Repeat getKey(15)
...
Horizontal -
DispGraph
ClrDraw

The screen doesn't really go left...

Offline Fast Crash

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 192
  • Rating: +45/-7
  • Virus of tomorrow
    • View Profile
Re: My Helicopter Game
« Reply #10 on: April 24, 2011, 05:57:31 am »
You erase it with ClrDraw, this is probably the problem :D

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: My Helicopter Game
« Reply #11 on: April 24, 2011, 06:02:01 am »
You erase it with ClrDraw, this is probably the problem :D

But I also have the player which goes up and down and I need to ClrDraw so that his previous positions disappear.

Offline ingalls

  • LV3 Member (Next: 100)
  • ***
  • Posts: 49
  • Rating: +4/-0
  • :)
    • View Profile
Re: My Helicopter Game
« Reply #12 on: April 24, 2011, 06:04:16 am »
All you need to add to the code is a timer statement. That way you can establish fps
« Last Edit: April 24, 2011, 06:11:13 am by ingalls »

Offline Fast Crash

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 192
  • Rating: +45/-7
  • Virus of tomorrow
    • View Profile
Re: My Helicopter Game
« Reply #13 on: April 24, 2011, 06:08:47 am »
Here is what i would do :

Repeat getkey(15)
... <Tests for players's position>
... <Tunnel/Blocks' display>
Pt-On(X,Y,[sprite])
Dispgraph
Pt-Change(X,Y,[sprite])
Horizontal -
End

Offline ingalls

  • LV3 Member (Next: 100)
  • ***
  • Posts: 49
  • Rating: +4/-0
  • :)
    • View Profile
Re: My Helicopter Game
« Reply #14 on: April 24, 2011, 06:12:09 am »
Fast crash's code is a lot easier to implement than what I was suggesting... The only problem with it is that the backgound is going to need to be moving as well so your probably going to want to add the timer statement that I was talking about.