Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => TI Z80 => Topic started by: Hayleia on February 18, 2014, 04:00:38 pm

Title: Flappy Bird - Hayleia
Post by: Hayleia on February 18, 2014, 04:00:38 pm
Many people already made their version of a Flappy Bird clone. So I thought "why not me too ?" :P
I think it is useless for me to explain the gameplay, it's in every other topic. So I guess it's just screenshot time (6MHz, as usual).
(http://img.ourl.ca/Crappy%20Bird.gif)

As you can see, collision detection is missing and the game needs a menu and such things so no release for now. I'd also like to optimize it a bit so you'll have to wait :P
Anyways, tell me what you think of it :)

Download here (http://ourl.ca/20709/377316)
Title: Re: Flappy Bird - Hayleia
Post by: LDStudios on February 18, 2014, 04:09:53 pm
I think with all of these flappy clones combined, we get more downloads than the real game.
Title: Re: Flappy Bird - Hayleia
Post by: Sorunome on February 18, 2014, 04:29:21 pm
So many flappy birds O.O
Title: Re: Flappy Bird - Hayleia
Post by: JWinslow23 on February 18, 2014, 04:54:18 pm
I, for one, welcome our new Flappy overlords. XD

Anyways, I love it! Better than ClrDraw's version! (And I don't say that often)
Title: Re: Flappy Bird - Hayleia
Post by: nspireguy on February 18, 2014, 08:38:08 pm
I think with all of these flappy clones combined, we get more downloads than the real game.
this could happen. now that you cant get the app...
Title: Re: Flappy Bird - Hayleia
Post by: ClrDraw on February 18, 2014, 11:05:08 pm
I really like the grayscake, good work! How big is it?
Title: Re: Flappy Bird - Hayleia
Post by: Hayleia on February 19, 2014, 12:41:13 am
I think with all of these flappy clones combined, we get more downloads than the real game.
Yeah, but unfortunately, we don't make money :P

Anyways, I love it! Better than ClrDraw's version! (And I don't say that often)
Well, thanks, but how can you say that before trying it ? :P

I really like the grayscake, good work! How big is it?
(grayscake ? :P)
Thanks :)
Compiled for Noshell, i's 3043 bytes for now (because of 1536 bytes for the background, but I could save a lot considering that half the background is monochrome).
Title: Re: Flappy Bird - Hayleia
Post by: ClrDraw on February 19, 2014, 10:48:14 am
Quote
(grayscake ?  :P)
Haha XD Either I suck at computers or I was thinking about portal too much!
But that's not a bad size considering the grayscale. I can't wait to play it :)
Title: Re: Re: Flappy Bird - Hayleia
Post by: DJ Omnimaga on February 19, 2014, 10:53:20 am
This looks quite good actually. What I am wondering is if parallax scrolling would slow the game down?
Title: Re: Flappy Bird - Hayleia
Post by: JWinslow23 on February 19, 2014, 11:53:12 am
Anyways, I love it! Better than ClrDraw's version! (And I don't say that often)
Well, thanks, but how can you say that before trying it ? :P
I saw the screenie. :p

Sure looks realistic. I might respond.
Title: Re: Flappy Bird - Hayleia
Post by: Hayleia on February 19, 2014, 12:20:50 pm
What I am wondering is if parallax scrolling would slow the game down?
It depends. If I keep everything 4 lvl of greyscale, then yes, it will slow down a lot. But if I scroll a white+grey background with only three levels of grey (pipes would be black then, but dark clouds would not be possible), then it will speed up.

Thanks everyone for the support :)
Title: Re: Flappy Bird - Hayleia
Post by: DJ Omnimaga on February 19, 2014, 01:01:15 pm
Ah ok thanks for the info. Is it just due to having to redraw everything or because of possible flicker?
Title: Re: Flappy Bird - Hayleia
Post by: Hayleia on February 19, 2014, 01:40:29 pm
Ah ok thanks for the info. Is it just due to having to redraw everything or because of possible flicker?
It's due to having to redraw everything. Right now, I just draw pipes once and then keep shifting. And you read right, I draw once, I don't keep drawing while it's half offscreen, I draw them once in L1 then shift L6 (and L3) with a part of L1 ;)
But If I went parallax (with 4 lvl of grey, 3 is not a problem as said previously), I'd have to draw all pipes, refresh screen, erase pipes according to their positions or reinitialize the background (don't know which is slower :P), shift the background then draw all pipes again. This is slow, but also forces the placement of the "refresh screen" part while with my current code, I can use an interrupt.
Title: Re: Flappy Bird - Hayleia
Post by: Hayleia on February 19, 2014, 06:15:52 pm
Ok, here's the full source code for now, in spoiler. Use at your own risks.
Spoiler For Spoiler:
.AFLAPPY
L2+00->°BirdY
L2+10->°BirdV
L2+02->°GreyMode
.the second argument to fnInt()
L2+04->°GreyTimer
L2+06->°GreyTimerMax
L2+12->°Key4

[]->°BirdSprites
[1C72F6301BFC7C00].dark grey and black
[0000040C03000000].light grey and black
[1C7EFEFFFFFF7C00].mask (white, both grey and black)

.-------------
Lbl Code
LnReg
."frees" L2
Fix 5
ExprOn

FnOff

1->GreyMode
{+°Delays}->GreyTimerMax->GreyTimer
0->BirdV->X

Calibrate()
FnOff

FillEdge()
16*256->BirdY
Copy(°BG1,L6)
Copy(°BG2,L3)
TurnGreyOn()

While 1
 X++Select(,Select(,-96??->X) and 7??FillEdge()) and 31
 !If
  ->r3
  rand and 15+1Asm(45)
  .->b
  L1-1Asm(EB)
  .->de
  L1+64
  .->hl
  Asm(AF)
  .->a
  Asm(233676EB23366EEB3C10F5)
  Asm(0604)
  Asm(2336EFEB2336DFEB3C10F5)
  Asm(2336FFEB2336FFEB)
  Asm(011800)
  Asm(09EB09EB)
  .PipeTopAgain
  Asm(2336FFEB2336FFEB)
  Asm(C60E).add a,14
  .PipeHeadAgain
  Asm(0604)
  Asm(2336EFEB2336DFEB3C10F5)
  .PipeBodyAgain
  Asm(F5)
  Asm(F1233676EB23366EEB3CF5EE3820F1)
  Asm(F1)
 End
 L1+63-5Asm(EB)L6+767-60Shift()
 L1+127-5Asm(EB)L3+767-60Shift()
 Key4 xor (getKey(4)->Key4) and Key4?~220,BirdV+(<<256*2*2*2*2)
 .->BirdV<<256??256,BirdV
 .maybe use max() here
 ->BirdV*2+BirdY->BirdY
 .DispGraph^^r^^r
EndIf getKey(15)

Lbl RET
LnReg
ClrHome
Return

Lbl FillEdge
L1-1->r1
L1+64-1->r2
X/8Select(,+°BG1-12->r3)+°BG2-12->r4
For(64)
 {r3+12->r3}->{r1+1->r1}
 {r4+12->r4}->{r2+1->r2}
End
Return

Lbl Shift
Asm(0640C5EBCB16EB1B060CCB162B10FBC110F0)
Return

Lbl EraseBird
BirdY/256+(*2)*2*2Select(,+L6+1-12->A)+L3+1-12->B
L1+128->C
For(7)
 {C++}->{A+12->A}
 {C++}->{B+12->B}
End
Return

Lbl DrawBird
BirdY/256+(*2)*2*2Select(,+L6+1-12->A)+L3+1-12->B
L1+128->C
For(7)
 {A+12->A}->{C++}
 {B+12->B}->{C++}
End
Pt-Change(8,BirdY/256,°BirdSprites+16)^^r
.now the area used by the bird is white
Pt-On(8,BirdY/256,°BirdSprites)
Pt-On(8,BirdY/256,°BirdSprites+8)^^r
Return

Lbl TurnGreyOn
fnInt(GreyOn,GreyMode*2)
Return

Lbl GreyOn
Asm(F5C5D5E5)
.push everything
.!If GreyTimer+1^GreyTimerMax->GreyTimer
!If GreyTimer--
 GreyTimerMax->GreyTimer
 sub(DrawBird)
 DispGraph^^r^^r
 sub(EraseBird)
End
Asm(E1D1C1F1)
.pop everything
Return

[]->°Nums
[FFE7D3D3D3C3E7FF]
[FFE7C7C7E7E7E7FF]
[FFE7D3F3E7CFC3FF]
[FFC3B9E3E3B9C3FF]

[0A040302]->°Delays
Lbl Calibrate
Fill(L6,6,255)
Fill(+1,6,0)
L3-1
For(2)
 Fill(+1,3,255)
 Fill(+1,3,0)
End
Copy(L6,+12,768-12)
Copy(L3,+12,768-12)
FnOff
Pt-Off(0,,GreyMode*8+°Nums)
TurnGreyOn()
While 1
 If getKey(3)-getKey(2)
  {+GreyMode^4->GreyMode+°Delays}->GreyTimerMax
  ->GreyTimer
  WLP()
  FnOff
  Pt-Off(0,,GreyMode*8+°Nums)
  TurnGreyOn()
 End
EndIf getKey(54)
Return

Lbl WLP
While 1
 Pause 20
End!If getKey(0)
Return

[]->°BG1
[0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000F80000000000000000000003FE0000000000000000000007FF000000E00000000400000FFF803C03F80000003F80000FFF80FF0FFE0000F0FFE0001FFFF9FFDFFF000FFCFFFF81FFFFFFFFFFFF003FFFFFFFE3FFFFFFFFFFFFF07FFFFFFFF7FFFFFFFFFFFFF8FFFFFFFFFFFFFFFFFFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000000000000000000000000000000]
[]->°BG2
[FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC07FFFFFFFF81FFFFFFFFFFF803FFFE1FFE007FFFFFFFFFF001FFF807FC003FC07FFF7FE000FFE003FC003F003FFF3E0000FE2001F8001F001FF0100000780000F8001E000FC0000000600000F00000000F80000000600000000000000780000000000000000000000700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF492492492492492492492492924924924924924924924924000000000000000000000000000000000000000000000000]
Can someone explain me why setting GreyMode at 0 plays faster than setting GreyMode at 3 ? Because that sets GreyTimerMax lower, but the frequency of the interrupt is also lower so nothing should happen more often.

edit and don't tell me "Draw and Erase are very very unoptimized, you are making the same calculation several times", I know, but I planned to change everything in the drawing routine anyway so I didn't look this part very often. And r3 in the main loop is useless, you can remove it.
Same for the "LnReg FnOff FnOff" at the beginning, the initialization when testing is always the first thing subject to changes.
Title: Re: Flappy Bird - Hayleia
Post by: Hayleia on February 20, 2014, 03:30:01 am
I just noticed on the screenshot that there was an unwanted white outline around "pipes" so I removed it here, but that still doesn't answer my interrupt question, so if anyone has a clue, please share. The code is in spoiler too.

Spoiler For Spoiler:
.AFLAPPY
L2+00->°BirdY
L2+10->°BirdV
L2+02->°GreyMode
.the second argument to fnInt()
L2+04->°GreyTimer
L2+06->°GreyTimerMax
L2+12->°Key4

[]->°BirdSprites
[1C72F6301BFC7C00].dark grey and black
[0000040C03000000].light grey and black
[1C7EFEFFFFFF7C00].mask (white, both grey and black)

.-------------
Lbl Code
LnReg
."frees" L2
Fix 5
ExprOn

FnOff

1->GreyMode
{+°Delays}->GreyTimerMax->GreyTimer
0->BirdV->X

Calibrate()
FnOff

FillEdge()
16*256->BirdY
Copy(°BG1,L6)
Copy(°BG2,L3)
TurnGreyOn()

While 1
 X++Select(,Select(,-96??->X) and 7??FillEdge()) and 31
 !If
  rand and 15+1Asm(45).->b
  L1-1Asm(EB).->de
  L1+64
  .->hl
  Asm(AF).->a
  .PipeBody
  Asm(F5237EE681F67677EB237EE681F66E77EBF13C10EB)
  Asm(0604)
  .PipeHead (with b=4)
  Asm(2336EFEB2336DFEB3C10F5)
  .PipeTop
  Asm(2336FFEB2336FFEB)
  .Add24
  Asm(011800)
  Asm(09EB09EB)
  .PipeTopAgain
  Asm(2336FFEB2336FFEB)
  Asm(C60E).add a,14
  .PipeHeadAgain
  Asm(0604)
  Asm(2336EFEB2336DFEB3C10F5)
  Asm(F5)
  .PipeBodyAgain (with push af first)
  Asm(237EE681F67677EB237EE681F66E77EBF13CF5EE3820E9)
  Asm(F1)
 End
 L1+63-5Asm(EB)L6+767-60Shift()
 L1+127-5Asm(EB)L3+767-60Shift()
 Key4 xor (getKey(4)->Key4) and Key4?~220,BirdV+(<<256*2*2*2*2)
 .->BirdV<<256??256,BirdV
 .maybe use max() here
 ->BirdV*2+BirdY->BirdY
 .DispGraph^^r^^r
EndIf getKey(15)

Lbl RET
LnReg
ClrHome
Return

Lbl FillEdge
L1-1->r1
L1+64-1->r2
X/8Select(,+°BG1-12->r3)+°BG2-12->r4
For(64)
 {r3+12->r3}->{r1+1->r1}
 {r4+12->r4}->{r2+1->r2}
End
Return

Lbl Shift
Asm(0640C5EBCB16EB1B060CCB162B10FBC110F0)
Return

Lbl EraseBird
BirdY/256+(*2)*2*2Select(,+L6+1-12->A)+L3+1-12->B
L1+128->C
For(7)
 {C++}->{A+12->A}
 {C++}->{B+12->B}
End
Return

Lbl DrawBird
BirdY/256+(*2)*2*2Select(,+L6+1-12->A)+L3+1-12->B
L1+128->C
For(7)
 {A+12->A}->{C++}
 {B+12->B}->{C++}
End
Pt-Change(8,BirdY/256,°BirdSprites+16)^^r
.now the area used by the bird is white
Pt-On(8,BirdY/256,°BirdSprites)
Pt-On(8,BirdY/256,°BirdSprites+8)^^r
Return

Lbl TurnGreyOn
fnInt(GreyOn,GreyMode*2)
Return

Lbl GreyOn
Asm(F5C5D5E5)
.push everything
.!If GreyTimer+1^GreyTimerMax->GreyTimer
!If GreyTimer--
 GreyTimerMax->GreyTimer
 sub(DrawBird)
 DispGraph^^r^^r
 sub(EraseBird)
End
Asm(E1D1C1F1)
.pop everything
Return

[]->°Nums
[FFE7D3D3D3C3E7FF]
[FFE7C7C7E7E7E7FF]
[FFE7D3F3E7CFC3FF]
[FFC3B9E3E3B9C3FF]

[0A040302]->°Delays
Lbl Calibrate
Fill(L6,6,255)
Fill(+1,6,0)
L3-1
For(2)
 Fill(+1,3,255)
 Fill(+1,3,0)
End
Copy(L6,+12,768-12)
Copy(L3,+12,768-12)
FnOff
Pt-Off(0,,GreyMode*8+°Nums)
TurnGreyOn()
While 1
 If getKey(3)-getKey(2)
  {+GreyMode^4->GreyMode+°Delays}->GreyTimerMax
  ->GreyTimer
  WLP()
  FnOff
  Pt-Off(0,,GreyMode*8+°Nums)
  TurnGreyOn()
 End
EndIf getKey(54)
Return

Lbl WLP
While 1
 Pause 20
End!If getKey(0)
Return

[]->°BG1
.take the hex code from the previous spoiler, I removed it because it caused a scroll bar to appear
[]->°BG2
.same here

I also attached a gif so you see what I am talking about. When I choose 0, the game plays fast, but when I choose 3 it is slower. I don't even understand why the slow down is this way. I would have understood 0 to be slower than 3 because it decreases GreyTimer more often (even though it DispGraphes as often), but it's 3 who is slower.
Title: Re: Flappy Bird - Hayleia
Post by: Hayleia on February 20, 2014, 01:19:06 pm
Sorry for quadruple posting, but there was an update each time. And this time, I am even releasing the game.
So enjoy if you like it, hate if you don't. Compiled for Ion.
Note that I got rid of interrupts in that version, I just put the DispGraphrr in the loop.

Use up to flap, clear to quit, 2nd to pause, +/- to change contrast (set back to normal when you quit).
Title: Re: Flappy Bird - Hayleia
Post by: JWinslow23 on February 20, 2014, 01:20:55 pm
+1d! :thumbsup:
Title: Re: Flappy Bird - Hayleia
Post by: Hayleia on February 20, 2014, 01:21:50 pm
+1d! ;D(http://www.omnimaga.org/Themes/default/images/gpbp_arrow_up.gif)
Thanks, but did you try before +1ing ? :P
It's blurry as hell. I really need to get interrupts back, but I don't know how to fix the problem mentionned in the previous page.

Also, the number at the bottom is your score.
Title: Re: Flappy Bird - Hayleia
Post by: TIfanx1999 on February 20, 2014, 01:52:11 pm
The game looks a good bit clearer in the most recent screen shot. The first screen shot you posted didn't look this good (or smooth). So anyhow, the speed looks great. Not sure about the blurriness on calc, but it doesn't look too bad in the most recent screenie.
Title: Re: Flappy Bird - Hayleia
Post by: Hayleia on February 20, 2014, 02:07:04 pm
Thanks :)
On calc not only you have blur, but you also have diagonal lines due to greyscale not being refreshed in a smart way -.-
Title: Re: Flappy Bird - Hayleia
Post by: DJ Omnimaga on February 20, 2014, 02:15:29 pm
I think that's inevitable in Axe, though, especially in scrolling games. :P
Title: Re: Flappy Bird - Hayleia
Post by: Hayleia on February 20, 2014, 02:17:21 pm
Well Rainbow Dash Attack had less flickering (not less blur) but for some reason, I don't manage to apply the exact same method with interrupts to that game (that's the problem mentionned on the previous page) ???
Title: Re: Flappy Bird - Hayleia
Post by: TheMachine02 on February 21, 2014, 09:46:57 am
By the way, why are you pushing (and pop after) all register at the begining of your interrupt routine ? That is useless, unless you use shadow register, wich I haven't saw in your code.
Title: Re: Flappy Bird - Hayleia
Post by: Hayleia on February 21, 2014, 11:17:28 am
I know it's useless but since I didn't know where that bug came from, I added that just in case. And it didn't solve anything.
Anyway, I gave up with interrupts and will only resume using them if someone solves the problem, so those unnecessary pushes/pops are nowhere (they are in comments).
Title: Re: Flappy Bird - Hayleia
Post by: Hayleia on February 24, 2014, 03:36:23 pm
Since Runer112 helped me find this issue (which was due to the fact DispGraphrr was slower than the interrupt frequency at speed 0 and disabled interrupts, so in fact, some frames were skipped while they shouldn't have been), I can now release a version using interrupts.

It is a bit slower but grey is constant (instead of popping when a new pipe is created behind the scenes).
Use Left/right in the calibration screen to choose a mode (choose the one where the grey is the less flickery of course) and +/- to change contrast (it will be set back to its initial value when quitting the game).

@JWinslow, unpause using 2nd too ;)

edit No, it is not so difficult. I don't manage to get more than 13 in the screenshot but on real calc I reached 15.
Title: Re: Flappy Bird - Hayleia
Post by: Sorunome on February 24, 2014, 03:45:23 pm
Make it as difficult as rainbow :trollface:
Title: Re: Flappy Bird - Hayleia
Post by: DJ Omnimaga on February 26, 2014, 10:39:00 pm
This looks much nicer actually. Gonna have to try it on my calc to see how it looks like. Is the grayscale constant on each calc via some LCD driver auto-calibration btw? I remember some ASM game did that, but I don't know if Axe programs or axioms can.
Title: Re: Flappy Bird - Hayleia
Post by: Hayleia on February 27, 2014, 03:06:25 am
Notice how I said "constant", and not "perfect" nor "beautiful" :P
It is just that it's not beautiful sometimes then ugly during a fraction of second when a pipe is created ;)

Normally, if you are not the most unlucky guy on earth, there should be one of the 4 modes that is not so ugly. But of course, using GrayLib would be better in terms of quality.