Author Topic: Flappy 3  (Read 809 times)

B+

  • Full Member
  • ***
  • Posts: 215
    • View Profile
Flappy 3
« on: July 06, 2015 »
Finally collision detection is by location not color:
(see Parallax thread for latest assets download)
Code: [Select]
rem
rem Flappy 3  2015-07-06 More code overhaul
rem          collision detection by pipe(x,y) and flappy(x,y) LOCATION!!!!   
rem          faster goundspeeds + more variance to pipe heights
rem          = more challenging

import "Speed.lib"

set window 200,0,432,768
set color 188, 255, 251
set redraw off

load image 1, "assets\clouds.png"
load image 2, "assets\city.png"
load image 3, "assets\trees.png"
load image 5, "assets\ground.png"
load image 7, "assets\intro.png"
load image 16, "assets\bird1.png"
load image 17, "assets\bird2.png"
load image 18, "assets\bird3.png"
load image 19, "assets\pipe200.png"
load image 20, "assets\pipe180.png"
load image 21, "assets\pipe150.png"

load sound 1, "assets\pop.wav"
load sound 2, "assets\bling.wav"
load sound 3, "assets\dead.wav"
load sound 4, "assets\flap.wav"

create font 0, "arial" , 42
set font 0

visible:
groundspeed# = 1.0
highscore=0

score = 0
scored = 0

bling = 2
dead = 3
flap = 4

flappyx = 75
flappyy = 300
pipey = -478

pipex# = 432.0
groundx# = 0.0
treesx# = 0.0
cityx# = 0.0
cloudsx# = 0.0
rem ======================== Main
proc intro
while keydown(27)=0
cls
proc movestuff
proc moveflappy
proc collision
proc updatescore
redraw
proc SPD_HoldFrame(140)
wend
end

rem
rem PROCEDURES
rem

procedure intro()
do
draw image 7, 0, 0
set color 0,0,0
set caret 217,650
center "High score today is "+str(highscore)
redraw
set color 188,255,251

if mousebutton(0) then
if mousex() > 166 and mousex() < 264 and mousey() > 366 and mousey() < 401 then
wait 1500
cls
break
elseif mousex() > 166 and mousex() < 264 and mousey() > 412 and mousey() < 446 then
cls
wait 500
end
endif
endif
if keydown(27) then end
loop
cls
endproc

procedure movestuff()
draw image 1, int(cloudsx#), 462
cloudsx#=cloudsx# -0.125*groundspeed#
if cloudsx# <= -432.0 then cloudsx# = 0.0

draw image 2, int(cityx#), 507
cityx# = cityx# -0.25*groundspeed
if cityx# <= -432.0 then cityx# = 0.0

draw image 3, int(treesx#), 552
treesx# = treesx# - 0.5*groundspeed#
if treesx# <= -432.0 then treesx# = 0.0

if groundspeed# <1.5 then
draw image 19, int(pipex#), pipey
elseif groundspeed# <2.0
draw image 20, int(pipex#), pipey
else
draw image 21, int(pipex#), pipey
endif
pipex# = pipex# - groundspeed#
if pipex# < -52.0 then
pipex# = 432.0
pipey=-600+rnd(250)
scored=0
endif

draw image 16, flappyx, flappyy

draw image 5, int(groundx#), 600
set color 0,0,0
set caret 217,650
center score
set color 188,255,251
groundx# = groundx# - groundspeed#
if groundx# <= -432.0 then groundx# = 0.0
endproc

procedure moveflappy()
if keydown(32) or mousebutton(0) then
flappyy = int(float(flappyy) -1.5)
play sound flap
else
flappyy = int(float(flappyy) +1.5)
endif
endproc

procedure collision()
rem hit top or ground?
if flappyy <-1 or flappyy >570 then
play sound(dead)
wait 1500
proc settlescore
endif

if flappyx-49<=int(pipex#) and flappyx+39>=int(pipex#) then
if groundspeed#<1.5 then
if flappyy <627 + pipey or flappyy > 630+pipey+170 then
play sound(dead)
wait 1500
proc settlescore
endif
elseif groundspeed# <2.0
if flappyy <637 + pipey or flappyy > 640+pipey+150 then
play sound(dead)
wait 1500
proc settlescore
endif
else
if flappyy <652 + pipey or flappyy > 655+pipey+120 then
play sound(dead)
wait 1500
proc settlescore
endif
endif
endif
endproc

procedure updatescore()
if flappyx >= int(pipex#)+52 and scored = 0 then
scored = 1
play sound(bling)
score = score + 1
if score <5 then
groundspeed# =1.4
elseif score <11
groundspeed#=1.9
else
groundspeed#=2.2
endif
endif
endproc

procedure settlescore()
if score>highscore then highscore=score
score = 0
scored = 0
flappyx = 75
flappyy = 300
pipey = -478
pipex# = 432.0
groundx# = 0.0
treesx# = 0.0
cityx# = 0.0
cloudsx# = 0.0
groundspeed#=1.0
proc intro
endproc

With current collision settings you will find Flappy crashed darn near if not on the pipes.
« Last Edit: July 06, 2015 by B+ »
B+

johnno56

  • Guest
Re: Flappy 3
« Reply #1 on: July 07, 2015 »
Well done. Definitely removes the 'colour' problem.

Now that colour is not an issue, I have some interesting background screens that could make for slightly more difficult gameplay... I will test it and if it works I will repost... Again, well done.  :D

J

johnno56

  • Guest
Re: Flappy 3
« Reply #2 on: July 07, 2015 »
Here is a prototype that includes themes. The graphic assets will change as the game proceeds (from 'Day' to 'Night').

The coding is not very efficient, but it works. Be my guest to modify as you see fit.

Enjoy

J

B+

  • Full Member
  • ***
  • Posts: 215
    • View Profile
Re: Flappy 3
« Reply #3 on: July 07, 2015 »
OK I named the theme additions Flappy 3-1, very refreshing to have changes of scenery!

For Flappy 3-2:

So let's cycle through the themes at every increase of 10 in score and while we are at it lets change up the speeds a little too.

Fix bugs:
In Intro Procedure (at top):
Code: [Select]
Randomize time()
In settlescore procedure (near end):
Code: [Select]
Theme = 0
New updatescore procedure:
Code: [Select]
procedure updatescore()
if flappyx >= int(pipex#)+52 and scored = 0 then
scored = 1
play sound(bling)
score = score + 1
if score % 10 = 0 then theme = theme + 1
if theme > 3 then theme = 0
if score <5 then
groundspeed# =1.4
elseif score <15
groundspeed#=1.9
else
if score % 15 =0 then
     groundspeed#=groundspeed#+0.1
     if groundspeed#>2.3 then groundspeed#=1.8
endif
endif
endif
endproc

That way we can see different pipes once and awhile too along with cycling of daylight.
B+

Marcus

  • Administrator
  • Hero Member
  • *****
  • Posts: 542
    • View Profile
Re: Flappy 3
« Reply #4 on: July 07, 2015 »
I will have a look at this game tonight, looks awesome.

My 5 week vacation just started, hope to post some games myself :)
.\\\opz

johnno56

  • Guest
Re: Flappy 3
« Reply #5 on: July 07, 2015 »
Nicely done, B+.

I had thought of cycling but didn't quite figure it out. Too tired...

Ah yes. You tweaked the speed a little too. I want to thank you for killing me off quicker! I was just getting used to the pace and developing a serious score of 90+. Now I have to practice a LOT more... :D

I have finally figured out how to load a true type font and I am experimenting. I tried the 'flappy' font but it didn't work (nuts), so I am trying out "Impact" and seems to be working just fine. I am going to tweak the size and colour and re-post the modification.

J

johnno56

  • Guest
Re: Flappy 3
« Reply #6 on: July 07, 2015 »
Font change:

Pop these lines in after the graphics and audio is loaded.
Quote
load font 0, "assets\impact.txt", "assets\impact.bmp"
set font 0

Near the top of intro() procedure, replace the three lines after draw image 7,0,0 with:
Quote
      set color 0,128,0
      set caret 217,650
      center "Hiscore today: "+str(highscore)

Near the bottom of movestuff() procedure, after draw image5, replace the next 3 lines with:
Code: [Select]
set color 0,128,0
set caret 217,650
center score

Don't forget to put the "impact.txt" and "impact.bmp" files into the assets folder. Otherwise you will have to guess your score.

Hope it's ok?

J

B+

  • Full Member
  • ***
  • Posts: 215
    • View Profile
Re: Flappy 3
« Reply #7 on: July 07, 2015 »
Font works great! Just have to remember to shorten the High Score message a bit.

I am up to Flappy 3.3:
Code: [Select]
rem
rem Flappy 3  2015-07-06 More code overhaul
rem          collision detection by pipe(x,y) and flappy(x,y) LOCATION!!!!   
rem          faster goundspeeds + more variance to pipe heights
rem          = more challenging
rem
rem Flappy 3.1 2015-07-07 Added "Themes" - J
rem        3.2 2015-07-07 added randomize in intro, theme = 0 in Settlescore proc
rem                       theme cycling every 10 in score, and groundspeed cycling every 15 in score
rem        3.3 2015-07-07 Johnno added new Impact Font for scores   
B+

B+

  • Full Member
  • ***
  • Posts: 215
    • View Profile
Re: Flappy 3
« Reply #8 on: July 20, 2015 »
Johnno,

Are you still interested in keeping Highscore in a separate file?



B+

johnno56

  • Guest
Re: Flappy 3
« Reply #9 on: July 20, 2015 »
A hiscore file would be nice, but it's not critical to the game. Besides, it would only serve to remind me, of how poorly I play... *sigh*

Nah, just kidding. If you want to add a hiscore file, be my guest...

J

B+

  • Full Member
  • ***
  • Posts: 215
    • View Profile
Re: Flappy 3
« Reply #10 on: October 19, 2016 »
Font works great! Just have to remember to shorten the High Score message a bit.

I am up to Flappy 3.3:
Code: [Select]
rem
rem Flappy 3  2015-07-06 More code overhaul
rem          collision detection by pipe(x,y) and flappy(x,y) LOCATION!!!!   
rem          faster goundspeeds + more variance to pipe heights
rem          = more challenging
rem
rem Flappy 3.1 2015-07-07 Added "Themes" - J
rem        3.2 2015-07-07 added randomize in intro, theme = 0 in Settlescore proc
rem                       theme cycling every 10 in score, and groundspeed cycling every 15 in score
rem        3.3 2015-07-07 Johnno added new Impact Font for scores   

So what happened to the actual program ???

There is nothing left of it except the starting REM comments  >:(

Who took the code?
« Last Edit: October 19, 2016 by B+ »
B+