Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => TI Z80 => Topic started by: dinosteven on September 09, 2012, 07:16:48 pm

Title: Bounce
Post by: dinosteven on September 09, 2012, 07:16:48 pm
This is my first real Axe game, Bounce! Inspired by Mr. Bounce by Pixelate - http://www.madebypixelate.com/games/mr-bounce (http://www.madebypixelate.com/games/mr-bounce) - and now for the TI 83/84s! It's a basically Breakout with gravity, and a few twists added in. (I haven't got the twists yet, just the basic engine.)

Bounce the ball with your paddle and try to get it to hit the targets, but don't drop it. You only have 1 life! You have about a minute to get everything before the timer runs out - you won't die when it does, but you don't get the bonus points.
My highscore so far is 630, can you beat it? (the default is 0 with "BLACKSCREEN  INC", the name of a group of my friends and I made up when we sold games in school)

I've attached prgms A, AA, BOUNCE, and BOUNCSRC. They are the level editor, the level editor's source, my BOUNCE game, and its source, respectively. I was pretty lazy when making the level editor, so it's not very good. If you screw up, exit, then type 0:Asm(prgmA) - it'll delete and reset the map.

Here's a screenshot:
(http://img707.imageshack.us/img707/6439/bouncev3showcase.gif)

I hope you like Bounce!
Title: Re: Bounce
Post by: dinosteven on September 09, 2012, 07:24:33 pm
If you know Axe, I'd like help drawing the title screen that I'll be adding; fixing the random glitch where it starts flickering and then you die; improving the level editor; fixing the leftover timer glitch; fixing the ball-breaking-wall glitch; adding pause, walls, path prediction and slowmo;  more additional features; etc...
I have a lot to do...
Title: Re: Bounce
Post by: blfngl on September 09, 2012, 07:26:24 pm
Very nice! Can't wait to play 7:^)
Title: Re: Bounce
Post by: dinosteven on September 20, 2012, 12:08:29 am
I've noticed that in many games with balls, the sprites are partially white.
EX: [0000182C3C180000]
Why is that so, and is my ball sprite of [003C7E7E7E7E3C00] bad to use?
Title: Re: Bounce
Post by: leafy on September 20, 2012, 12:14:33 am
Absolutely not. All sprites take (roughly) the same amount of time to draw. The only difference you'll see in drawing is when the sprite is aligned to L6 bytes (i.e. aligned to every column of 8 pixels)
Title: Re: Bounce
Post by: dinosteven on September 20, 2012, 12:17:29 am
What about aesthetics?
Title: Re: Bounce
Post by: leafy on September 20, 2012, 12:28:25 am
The sprite is just as good as you make it. Whether a pixel is white or not makes little difference; the conglomerate is all that matters. If you choose to have your ball with a slight shine to it, or a solid ball, make sure it works well with the game.
Title: Re: Bounce
Post by: dinosteven on September 20, 2012, 12:35:24 am
Thanx. I need the ball to be entirely solid - hit detection depends on pxl-test()s and there's always the chance that the ball hits, but the white part is exactly over the pxl-test() location. And the ball looks fine in my game.
Title: Re: Bounce
Post by: aeTIos on September 20, 2012, 07:35:38 am
Screenshits?
Title: Re: Bounce
Post by: dinosteven on September 20, 2012, 07:56:45 am
Sure!
Here's one. Unfortunately, there's something wrong with the timer - it leaves behind some residue.
Title: Re: Bounce
Post by: aeTIos on September 20, 2012, 08:51:36 am
Hm looks nice. However, you might make the ball some smaller.
Title: Re: Bounce
Post by: Stefan Bauwens on September 20, 2012, 12:43:53 pm
Looks nice! Well done. :)
Title: Re: Bounce
Post by: dinosteven on September 20, 2012, 06:49:42 pm
Thanks!
I'll use a smaller ball if anyone can provide a hex code for it. No white holes, please.
*as a side note, that animated bug on your signature is making me want to hit my monitor.

I also have an idea for the menu - choices in the middle, lined horizontally, and you have a paddle and ball bouncing just below the choice. The player moves the ball under the selection and increases the height to hit it! The ball would probably move left/right with the paddle, no real bounce physics. (So beginners have an easier time.) What do you think?
Title: Re: Bounce
Post by: blfngl on September 20, 2012, 09:08:03 pm
That would be nice! If that is implemented maybe there could be an option to turn that on and off, the off state being the default bounce height it is right now.
Title: Re: Bounce
Post by: Sorunome on September 20, 2012, 10:53:56 pm
Looking nice! Nice physics over there :D
Title: Re: Bounce
Post by: dinosteven on September 23, 2012, 10:39:45 am
So... problems. Because of my roots as a BASIC proger, I've been optimizing as much as possible. The high score routine is embedded inside the game, but now I have to pull it out into a subroutine so the menu can call it.
So I used sourcecoder to cut/paste it into the bottom, and had it run a subroutine - just to test if it worked. When I tested it on Tilp2, the Highscore turned into a bunch of random mumbo-jumbo and the calc froze... I don't wanna test it on my own calc...
Here's the code:
Spoiler For Problem Code:
:.BOUNCE
:[003C7E7E7E7E3C00]→Pic1
:[106C4482446C1000]→Pic2
:"vBOUNCMP"→Str1
:"vBOUNCE"→Str2
:!If GetCalc(Str2)→H
:GetCalc(Str2,18)→H
:0→{H}{^r}
:conj("BLACKSCREEN  INC",H+2,16)
:End
:!If GetCalc(Str1)→M
:GetCalc(Str1,48)→M
:DeltaList(10,11,10,21,10,31,10,41,20,11,20,21,20,31,20,41,30,11,30,21,30,31,30,41,40,11,40,21,40,31,40,41,50,11,50,21,50,31,50,41,60,11,60,21,60,31,60,41)→GDB1
:conj(GDB1,M,64)
:End
:DiagnosticOff
:ClrDraw{^r}{^r}
:For(A,0,23)
:{2*A+M}→X
:{2*A+1+M}→Y
:Pxl-On(X,Y){^r}
:Pt-On(X-3,Y-3,Pic2){^r}
:End
:375→T
:37→X→B
:53→Y
:5→D→C→F
:0→E→S→I→J→G
:ref(0,0,5,60)
:ref(70,0,5,60)
:Fix 5
:Repeat (Y≥56) or getKey(15) or (G=1)
:If T≠0
:T--
:End
:Pt-On(X,Y,Pic1)
:ref(B-8,60,16,2)
:Text(76,0,"Score")
:Text(76,6,S►Dec)
:rref(76,12,8,50){^r}
:ref(76,62-(T*2/15),8,T*2/15){^r}
:DispGraph{^r}
:1→G
:For(I,0,23)
:{2*I+M}→K
:{2*I+1+M}→L
:If pxl-Test(K,L){^r}
:0→G
:If pxl-Test(K,L)
:S+F→S
:F+10→F
:Pxl-Off(K,L){^r}
:Pt-Change(K-3,L-3,Pic2){^r}
:End
:End
:End
:Pt-Change(X,Y,Pic1)
:If (D>64) and pxl-Test(4+X,8+Y)
:C→D
:5→F
:4+X-B/2+E→E
:End
:If pxl-Test(X-1,Y+4) or pxl-Test(X+9,Y+4)
:0-E→E
:End
:X+E→X
:Y-D→Y
:D--
:rref(B-8,60,16,2)
:If getKey(14)
:sub(H)
:Return
:End
:If getKey(1)
:C--
:End
:If getKey(2)
:B-2→B
:End
:If getKey(3)
:B+2→B
:End
:If getKey(4)
:C++
:End
:C+10^5+5→C
:If B>66
:66→B
:End
:If B<9
:9→B
:End
:Pause 99
:End
:Fix 4
:If G=1
:S+T→S
:End
:ClrHome
:Disp "Score:",S►Dec
:If S>{H}{^r}
:S→{H}{^r}
:Output(0,2)
:Disp "New Highscore!",{i}
:0→A
:Disp "Type Your Name:"
:Output(0,4)
:"WRMH"→GDB5
:det(3)
:"VQLG"
:det(3)
:"ZUPKFC"
:det(1)
:" YTOJEB"
:det(2)
:"XSNIDA"
:"                "→GDB9
:Repeat B=54 and (A≠0
:getKey→B
:If B=56 and (A≠0
:A--
:Output(A,5,' '►Frac)
:Output(A,5)
:End
:If B=15
:0→A
:Output(0,5,GDB9)
:Output(0,5)
:End
:If A<16
:If B>10 and (B<48)
:If {B+GDB5-11}→C
:Disp C►Frac
:C→{A+{L1}}
:A++
:End
:End
:End
:End
:0→{A+{L1}}
:conj({L1},H+2,16)
:End
:Return
:Lbl H
:ClrDraw{^r}{^r}
:Text(20,0,"High Score:")
:Text(5,8,H+2)
:Text(80,8,{H}{^r}►Dec)
:DispGraph
:Return
A few commands are weird; it's the BASIC version of them. I've also attached 2 files; BOUNCSRC is the original that works; BOUNCSRS (1) is the funky one. Anyone know what's going on?
Title: Re: Bounce
Post by: shmibs on September 23, 2012, 05:44:22 pm
i haven't looked at the rest of your code yet to see if there might be any other problems, but one thing that has caused such issues for me in the past was the fact that sourcecoder turns the small v token axe uses to designate appvars into the actual lowercase letter. if the program you got out of sourcecoder is using

:"vBOUNCMP"→Str1
:"vBOUNCE"→Str2

then try editing those on the calculator and changing them back to the 2nd+8 token.
Title: Re: Bounce
Post by: dinosteven on September 23, 2012, 07:42:46 pm
Yup, that's it. I changed it, and it works now!
That's pretty bad, though; I'm going to have to do that whenever I use sourcecoder. I'm either going to have to do this on calc, or switch to my Windoze partition to use Tokens/BexIDE...
And this problem has consumed my weekend; I'll have to wait for the next weekend to keep working.
Title: Re: Bounce
Post by: shmibs on September 24, 2012, 08:59:01 pm
tokens runs just fine under mono, so there's no reason you have to boot into wondows.
Title: Re: Bounce
Post by: dinosteven on September 24, 2012, 09:18:03 pm
Really? Thanks, I'll try it!
Title: Re: Bounce
Post by: dinosteven on September 28, 2012, 11:27:45 pm
I've managed to get the menu working, and I've reorganized my code so it works.

New features:
Spoiler For Features:
Menu - Highscores, Play and Quit are working; About will be added in shortly. Choosing About will just reset the Menu.
*Also, I seem to have neglected to give you the controls. They'll come shortly.
Changed ball sprite to a square, like the original game. Unfortunately, as wall-breaking isn't fixed, this causes some problems sometimes.
Did some things to try and stop wall-breaking. Failed.
Ball now starts in center of paddle, so you don't have to act the instant it starts.
Now, for the Controls:
Spoiler For Controls:
Left to move the paddle Left; Right to move the paddle Right.
The ball will move with the paddle in the menu, but not in-game. It will bounce 'away' from the paddle if it doesn't hit the center of the paddle.
Up/Down to change the ball's height. Height scrolls in-game, but on in the menu.
Clear to quit. In the menu, it exits; in-game, it acts as if you lost.
To select an item, move the ball under the choice and change the height so it hits the letters.
You can also hit [2nd] to instantly select.
When text is on the screen, hit [2nd] to continue.
To Do:
Spoiler For To Do:
Fix Bugs (see below)
Add the About choice.
Fix the logo.
More on the level editor
Add slowmo and pause features (there's more, but that's all for now)
I've also got a lot of glitches that I can't seem to fix.
If you know Axe, please go to page one and download my source! I need help fixing these bugs... Any help would be appreciated!

Bugs:
Spoiler For Bugs:
Sometimes the ball goes through the wall, and if it goes far enough, will bounce from it, messing it up completely. I added:

:If X>70
:70→X
:End
:If X<1
:1→X
:End

but it still goes through the wall sometimes! (Although not as often as before.) I don't understand!

Sometimes the ball will start flashing, skipping. It's hard to explain, but if you play it a few times, you'll see it. When it does this, there's no way to catch it - you'll lose when it comes down, even if your paddles located perfectly. idk why this happens and how to fix this.

The gray scale timer leaves behind residue as it moves down. I have no idea what's happening here.

I think that's all the bugs! Please help fix this if you can!

And that's all! As a final note, don't hold down [2nd] to progress. Tap it. Otherwise, it'll detect another [2nd] and you'll play the game again rather than going back to the menu. I'll try to fix that soon.
Title: Re: Bounce
Post by: Sorunome on September 29, 2012, 03:07:41 am
Looks pretty cool! And to the going off side, make sure that your if-conditions are directly after recalculating the position of the ball.
And to your 2nd problem - just use a different key in one case XD
Title: Re: Bounce
Post by: dinosteven on September 29, 2012, 11:28:19 am
Yeah, that seemed to be the problem. I had the safeguards set before I updated the variables. Just moved the code.
Unfortunately, after 5 test runs, it broke the wall. But it happens way less often now and it doesn't break the game.  :)

But I don't understand what this means:
And to your 2nd problem - just use a different key in one case XD
??? Please explain!
Title: Re: Bounce
Post by: Sorunome on September 29, 2012, 12:50:25 pm
you use for both thingies the 2nd key, so if you hold it to long it opens the game again. If you use for one thingy like alpha it wouldn't happen as that key doesn't have a function in the menu
Title: Re: Bounce
Post by: dinosteven on September 29, 2012, 04:01:20 pm
Oh, I see what you mean. But [2nd] is really the best choice...

OK. After some digging, I found ztrumpet's Jump! source. He solved it like this:
Code: [Select]
While getKey(54)
Pause 50
End
So the user has to let go of [2nd] before it does anything, fixing it! He's a genius.
Problem solved.
Title: Re: Bounce
Post by: Sorunome on September 29, 2012, 04:38:37 pm
Oh, nice idea :D But wouldn't it also work without the pause? ;)
Title: Re: Bounce
Post by: dinosteven on September 29, 2012, 06:49:43 pm
I tried:
Code: [Select]
:Repeat getKey(0)
:End
it didn't work. :(
But you can save a byte in the source by using
:Pause 9
rather than
:Pause 50
I just tried it; it works.
Title: Re: Bounce
Post by: leafy on September 29, 2012, 06:56:48 pm
Shouldn't it be:

Code: [Select]
While getKey(0)
End

or more optimized (I think)

Code: [Select]
While 1
EndIf getKey(0)

if you want the same functionality as zTrumpet's code?

A trick I like using to make sure the player doesn't hold the button, but at the same doesn't use the getKey→ function is to do this (using 2nd as an example)

Code: [Select]
If getKey(54)
If K
0→K
[code goes here]
End
Else
1→K
End

I'm sure there's more optimized ways to do it, but that's one of the easiest ways to understand how it works.
Title: Re: Bounce
Post by: Deep Toaster on September 29, 2012, 07:16:30 pm
Oh, nice idea :D But wouldn't it also work without the pause? ;)
It doesn't for me. Pause 8 seems to be the smallest pause that allows the code to work correctly.
But you can save a byte in the source by using
Smaller source doesn't always mean smaller program. Sometimes it's actually larger :) (In this case it's the same size.)
Title: Re: Bounce
Post by: Sorunome on September 29, 2012, 08:16:45 pm
Oh, nice idea :D But wouldn't it also work without the pause? ;)
It doesn't for me. Pause 8 seems to be the smallest pause that allows the code to work correctly.
why does it need pause?
Title: Re: Bounce
Post by: Deep Toaster on September 29, 2012, 08:18:58 pm
Oh, nice idea :D But wouldn't it also work without the pause? ;)
It doesn't for me. Pause 8 seems to be the smallest pause that allows the code to work correctly.
why does it need pause?
Otherwise it records zero once in a while even if a key is held down, because the keypad doesn't update fast enough.
Title: Re: Bounce
Post by: dinosteven on September 29, 2012, 11:55:47 pm
But you can save a byte in the source by using
Smaller source doesn't always mean smaller program. Sometimes it's actually larger :) (In this case it's the same size.)
How can a smaller source mean a bigger program? Can you give me an example?
Title: Re: Bounce
Post by: cooliojazz on September 30, 2012, 03:35:46 am
A+B+C+D+E+F+G+H+I+J->K (21 bytes) compiles to 71 bytes.  Pt-On(A,B,C) (7 bytes) compiles to 146 bytes.  Some routines are bigger than others when compiled, using a couple larger routines can make the compiled program huge, even if your source seems small, while using a ton of smaller routines can keep the size down.
Title: Re: Bounce
Post by: Hayleia on September 30, 2012, 07:04:22 am
Another example:

.AA
[FFFFFFFFFFFFFFFF]->Str1
ClrDraw
Pt-Off(0,,Str1)
Pt-Off(8,,Str1)
DispGraph
Pause 1800

   
.AA
[FFFFFFFFFFFFFFFF]->Str1
ClrDraw
Pt-Off(0,,Str1)
Rect(8,,,)
DispGraph
Pause 1800

Both take 68 bytes of source code but the first one takes 274 bytes of compiled code while the second one takes 386 bytes. And they both do the same thing (draw two black squares).
Why so ? Because the first one only uses the Pt-Off routine, while the second one uses the Pt-Off routine and the Rect routine, adding bytes to the executable ;)
Title: Re: Bounce
Post by: dinosteven on September 30, 2012, 09:39:34 am
So Rect is 112 bytes larger than pt-on? Wow, that's huge. That means that I can save 112 bytes by using Pt-On for my paddle!
Title: Re: Bounce
Post by: MGOS on September 30, 2012, 09:54:24 am
So Rect is 112 bytes larger than pt-on? Wow, that's huge. That means that I can save 112 bytes by using Pt-On for my paddle!
No, it isn't. Rect is 112 bytes large in total. The routines are only added to your program if they occur at least once in the source. So basically using two times Pt-Off will only add one Pt-Off to the program, and every times you need it, the function is called (like a subroutine).
You can save bytes by using only one type of routines (e.g. all Pt-Off or all Rect) instead of having different.
Title: Re: Bounce
Post by: dinosteven on September 30, 2012, 10:44:07 am
Oh... that makes more sense.
I need Rect for something else anyways, so I don't need to change anything.

Do you have any ideas on how to do slow-motion? I need something that slows the ball's movement, but not the timer or the paddle. I can't change its velocity; it won't land and bounce properly if I do - that's the cost of simulating gravity more accurately. And Pause doesn't work 'cause it slows everything down. I'm stuck.
Title: Re: Bounce
Post by: Sorunome on September 30, 2012, 12:54:53 pm
Maybe add some pause in the main loop?
Title: Re: Bounce
Post by: dinosteven on September 30, 2012, 01:16:03 pm
No, 'cause the paddle and timer are processed in the main loop. I could possibly make a separate engine for the ball and tell it to run X number of times...
But then the default non slow-motion speed would be at least 2 times as fast as it is now.
And that's a lot of work to do...
Any other ideas?
Title: Re: Bounce
Post by: MGOS on September 30, 2012, 02:44:02 pm
Simply add a counter variable, and do stuff only when the variable is dividable by 2,3 or 4 or what ever.

example

Code: [Select]
While 1   ; The main loop
C++

If C^2
This stuff is executed only every other time
End

This is always executed

EndIf getkey(15)
Title: Re: Bounce
Post by: chickendude on September 30, 2012, 02:56:39 pm
What you can do is add a timer for just the ball. Normally it can be set at, say 1, meaning that every time it reaches 0 (meaning every frame) you move the paddle. Later when you want slow motion, you can change the default delay to 2 or 3 so that it waits 2 or 3 frames before doing anything. If you want it to move just a little slower than everything else, set the timer to, say, 5, and run your routine to move the ball every time you update the timer EXCEPT when you reach 0. For every 5 frames that your paddle runs, the ball will be updated 4 times.

EDIT: something i do in asm all the time is use a counter and when it is divisible by 2/4/8/16 do something:
ld hl,timer
inc (hl)
ld a,(hl)
and $7 ;%111
ret z ;if bottom-most bits are 0, (meaning divisible by 8) don't update the ball.

if a = 0 it means that it is divisible by 8, it's really quick. Doing modulus 3/some other complicated number might be a bit more slow and take up more space. You could use and $3, and $1, or even and $15 depending on how much of a delay you want.
Title: Re: Bounce
Post by: dinosteven on September 30, 2012, 06:29:17 pm
Nice idea; I'll try slowing it down by a factor of 2. I have no idea what your asm code means, though...

Unfortunately, I tried messing with code too much and got stuck in an infinite loop... RAM clear... I'll try and fix the damage from a backup, then implement slow motion.

EDIT: RAM Clear wasn't to disastrous. Thank god for my obsessive backup-ing... I think I have everything back to what it was now. Time to add slowmo!

EDIT EDIT: Calc frozen now... idk why... gonna take out the batteries and re re write BOUNCE...
*sigh
Title: Re: Bounce
Post by: dinosteven on October 06, 2012, 09:30:32 pm
Added slowmo (infinite for now), reordered some code, made the ABOUT, and fixed the 2nd issue. BOUNCE and BOUNCSRC have been updated on my 1st post.
I would've had this sooner, but RAM clears came. I had FOUR RAM CLEARS this week, each one restarting my progress. ARGGH.
3 bugs left: ball randomly deciding to skip, ball breaking the wall (less common occurrence now), and the time meter residue.

So what's wrong with my time meter? Here's what I've got:
Code: [Select]
:RectI(76,12,8,50)^r
:Rect(76,62-(T*2/15),8,T*2/15)^r
T is the amount of time left. I can't find the problem. ???
Title: Re: Bounce
Post by: dinosteven on October 25, 2012, 09:52:04 pm
Allright, it's been a while, but now there's some updates.
Slowmo has a meter now
Buttons [Window] [Zoom] [Trace] [Graph] now are buttons for menu selection. (Maybe, not sure if I implemented it before I uploaded.)
Mode to Pause, [2nd] to unpause (it saved memory to use that subprgm)
Again, not sure if it's in the update.
Things to do:
I think I can save a few bytes by reordering code.
Path prediction
fixing the glitches
level editor?
Title: Re: Bounce
Post by: dinosteven on October 31, 2012, 08:18:44 pm
Optimized a few bytes.