Log In  

Cart #r56oh-0 | 2020-05-06 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

A game made in 560 characters for TweetTweetJam 4. The sound effects are generated from the poke commands at the top. The note pattern is random and can be a little unfair at times. I wanted to try a smarter way to generate the notes, but with 560 characters, there's not much room.

Z or C - Top line
X or V - Bottom line

If you're looking for a more readable version of the source code, check the spoiler:

-- The Poke commands generate the music, poke4 creates the first two notes
-- the first poke2 creates the third note (when you miss)
-- the last poke2 sets the speed of the notes (16)
c=0  -- combo count.
h=0  -- high score.
t={} -- notes in play.
m={} -- flags if you hit a button and missed a note (for both bars).
o=0p=0 -- delay between note generation, so 40 of them don't stack on top of each other.
_set_fps(60) -- set fps to 60, so the scrolling doesn't look awful
::e:: -- normally, gotos are ugly, but for code golf, they're a necessary evil.
-- clear screen and render the bars. A rectangle generates both lines.
-- reset and tick down parameters for next frame.
-- generate a note randomly, if it's created, add delay until next note (p and o).
if(rnd(25)<1 and o<0)add(t,{x=127,y=53,b=4})o=12
if(rnd(25)<1 and p<0)add(t,{x=127,y=69,b=5})p=12
-- loop over each note, see if it was correctly played, missed, etc...
for i in all(t)do
i.x-=1 -- come on down, you're the next contestant!
?"♪",i.x,i.y,12 -- draw the note
-- if note was played inside the circle, play the sound, 
-- remove it from play, and signify the player didn't miss,.
if(btnp(i.b)and i.x>=8 and i.x<=20)sfx(0,0,i.b-4,1)del(t,i)c+=1m[i.b]=0
-- if the player missed. remove their combo, play the missed note sound.
if(btnp(i.b)and m[i.b]>0)sfx(0,0,2,1)c=0
-- if the note left the screen, remove it from memory.
-- if the current combo is higher then the old one, add it to the high score.
-- print hud
?"combo: "..c,5,5,6
?"high: "..h,90,5
-- render the crowd, have them dance to the left and right depending on the note hit.
for i=0,4 do
-- draw to the screen, loop back to the beginning.
flip()goto e

P#75933 2020-05-06 05:01 ( Edited 2020-05-06 06:40)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2023-12-05 22:18:41 | 0.011s | Q:10