Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: Tgooseman on April 23, 2011, 03:49:30 pm

Title: My Helicopter Game
Post by: Tgooseman 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.
Title: Re: My Helicopter Game
Post by: Fast Crash 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.
Title: Re: My Helicopter Game
Post by: Munchor 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.
Title: Re: My Helicopter Game
Post by: ingalls 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
Title: Re: My Helicopter Game
Post by: Tgooseman 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?
Title: Re: My Helicopter Game
Post by: Fast Crash on April 23, 2011, 05:22:03 pm
Pt-Change(X,Y,[yoursprite]) will erase the sprite ( if it is at the same position )
Title: Re: My Helicopter Game
Post by: ingalls 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
Title: Re: My Helicopter Game
Post by: ingalls 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...

Title: Re: My Helicopter Game
Post by: Michael_Lee 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).
Title: Re: My Helicopter Game
Post by: Munchor 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...
Title: Re: My Helicopter Game
Post by: Fast Crash on April 24, 2011, 05:57:31 am
You erase it with ClrDraw, this is probably the problem :D
Title: Re: My Helicopter Game
Post by: Munchor 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.
Title: Re: My Helicopter Game
Post by: ingalls 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
Title: Re: My Helicopter Game
Post by: Fast Crash 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
Title: Re: My Helicopter Game
Post by: ingalls 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.
Title: Re: My Helicopter Game
Post by: Munchor on April 24, 2011, 07:57:41 am
@Fast_Crash: Thanks much. I'll try that.
Title: Re: My Helicopter Game
Post by: Fast Crash on April 24, 2011, 08:23:04 am
Add the Pixels-Test after the "Dispgraph" too ( if the player hits a wall )
Title: Re: My Helicopter Game
Post by: Munchor on April 24, 2011, 08:28:57 am
Code: [Select]
.HELI
DiagnosticOff
29->Y
Repeat getkey(15)
If getKey(1)
Y-2->Y
End
Y-1->Y
.I always decrease Y by 1 because a helicopter has to fall
Pt-On(X,Y,[sprite])
Dispgraph
Pt-Change(X,Y,[80C0E0F0E0C08000
.LOSING CODE
If pxl-Test(X,Y+7)
Return
End
If pxl-Test(X,Y-1)
Return
End
.END OF LOSING CODE
Horizontal -
End

I guess all I have left is displaying the tunnel.
Title: Re: My Helicopter Game
Post by: Fast Crash on April 24, 2011, 09:11:35 am
More optimized :

Code: [Select]
...
.LOSING CODE
If Pxl-Test(X,Y+7)+Pxl-Test(X,Y-1)
Return
End
.END OF LOSING CODE
...
Title: Re: My Helicopter Game
Post by: Munchor on April 24, 2011, 09:25:34 am
More optimized :

Code: [Select]
...
.LOSING CODE
If Pxl-Test(X,Y+7)+Pxl-Test(X,Y-1)
Return
End
.END OF LOSING CODE
...

Good idea.
Title: Re: My Helicopter Game
Post by: ZippyDee on April 24, 2011, 09:36:29 am
More optimized :

Code: [Select]
...
.LOSING CODE
If Pxl-Test(X,Y+7)+Pxl-Test(X,Y-1)
Return
End
.END OF LOSING CODE
...

is + smaller than OR? I never even thought about that comparison...If so, then I may have some optimizing to do (I needed a LOT of conditions)
Title: Re: My Helicopter Game
Post by: Munchor on April 24, 2011, 09:38:33 am
More optimized :

Code: [Select]
...
.LOSING CODE
If Pxl-Test(X,Y+7)+Pxl-Test(X,Y-1)
Return
End
.END OF LOSING CODE
...

is + smaller than OR? I never even thought about that comparison...If so, then I may have some optimizing to do (I needed a LOT of conditions)

+ doesn't mean or remember.

However, here's my study:
Size of program with +: 723bytes
Size of program with or: 725 bytes
Size of program with two if blocks: 726 byes
Title: Re: My Helicopter Game
Post by: ZippyDee on April 24, 2011, 09:40:24 am
More optimized :

Code: [Select]
...
.LOSING CODE
If Pxl-Test(X,Y+7)+Pxl-Test(X,Y-1)
Return
End
.END OF LOSING CODE
...

is + smaller than OR? I never even thought about that comparison...If so, then I may have some optimizing to do (I needed a LOT of conditions)

+ doesn't mean or remember.

However, here's my study:
Size of program with +: 723bytes
Size of program with or: 725 bytes
Size of program with two if blocks: 726 byes

I am aware that + doesn't mean or, but it works just fine for the purposes I have. I had always just assumed or was smaller. It's good to know that there are more optimizations to be done :D
Title: Re: My Helicopter Game
Post by: Tgooseman on May 22, 2011, 12:15:42 pm
So now that track is finally done I could actually work on my first game some more. I even made a screen shot .gif thing. It is pretty crappy but you get the basic idea.  I plan on adding difficulties (higher brick frequency, faster) and making it look a lot better.
Title: Re: My Helicopter Game
Post by: Munchor on May 23, 2011, 02:59:22 am
The image provided by that emulator is not very good, perhaps you could use Wabbitemu (Windows and Mac only though).

Either way, nice to see you managed to make it.
Title: Re: My Helicopter Game
Post by: Tgooseman on May 23, 2011, 10:06:31 pm
I tried using calc capture but with a wabbitemu configuration. Maybe I just didn't do it right?
Title: Re: My Helicopter Game
Post by: calcdude84se on May 23, 2011, 11:04:06 pm
You don't need to use calccapture because WabbitEmu can take recordings itself :D
It's configurable in the options, and you can start it by right-clicking on the screen and choosing the appropriate option or by pressing the backspace key (hopefully).
Title: Re: My Helicopter Game
Post by: Tgooseman on May 23, 2011, 11:23:31 pm
Well that is great to know for future use. Thanks!
Title: Re: My Helicopter Game
Post by: calcdude84se on May 23, 2011, 11:26:17 pm
Always willing to help :)
Also, by the screenshot it seems to work rather well, so congrats on your game! ;D
Title: Re: My Helicopter Game
Post by: DJ Omnimaga on May 25, 2011, 04:42:01 am
Looks nice. I like how this one has blocks instead of just a tunnel. It makes it different from all other helicopter games. Congrats on your first game. :)
Title: Re: My Helicopter Game
Post by: Munchor on May 25, 2011, 09:33:39 am
Looks nice. I like how this one has blocks instead of just a tunnel. It makes it different from all other helicopter games. Congrats on your first game. :)

Well mine has blocks too :P

Either way, as calcdude said Wabbitemu records GIFs itself :)