Log In  
Follow
kozm0naut
Bouncy Ball
by
[ :: Read More :: ]

Hi there!

I've been using a relatively simple system for sprite animations that I find works pretty well without much overhead. It relies on a simple function to retrieve the current frame of an animation frame list (ani) based on time (t()) and a given speed (spd) in frames per second:

--get animation frame
function anifrm(ani,spd)
 return ani[1+flr(spd*t()%#ani)]
end

That's it!

Now all we need is to define an animation as a list of sprite IDs:

--define player walk animation
pwalkani={2,3,4,5}

And we can assign this animation to our player just like assigning a single sprite:

--in _update(), during walk logic (e.g. btn left or right)
player.sprite=anifrm(pwalkani,10)

--in _draw(), using the normal spr() call
spr(player.sprite,player.x,player.y)

Here's an example cart to demonstrate fully, also taking sprite flipping into account:

Cart #koz_anidemo-1 | 2024-06-23 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
1


Full code:

player={
 x=60,
 y=60,
 sprite=1,
 sprflip=false
}

--define player walk animation
pwalkani={2,3,4,5}

--get animation frame
function anifrm(ani,spd)
 return ani[1+flr(spd*t()%#ani)]
end

function _update()
 if btn(⬅️) then
  player.x-=1
  player.sprite=anifrm(pwalkani,10)
  player.sprflip=true
 elseif btn(➑️) then
  player.x+=1
  player.sprite=anifrm(pwalkani,10)
  player.sprflip=false
 else
  player.sprite=1
  player.sprflip=false
 end
end

function _draw()
 cls()
 spr(player.sprite,player.x,player.y,1,1,player.sprflip)
end

Be aware that because this function is tied to global time (t()) the current frame shown isn't dependent on when the action began/the animation was set.

Good luck and feel free to let me know if there are any questions or comments about this function or its usage!

P#151210 2024-07-12 04:54

[ :: Read More :: ]

srviv

Wield your blessed golden chakram against the oncoming vampire bat horde! Survive and take out as many as you can!

Survivors-type made in under 500 chars for tweettweetjam9. Check it out on itch.io

Cart #srviv-0 | 2024-05-13 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
5

Reload the page to try again. I ran out of characters for a more elegant ending.

Code below...

l=128x=64y=64c=0v=0p=0m=64n=64z={}r=rnd β˜…=sin 🐱=cos …=atan2 πŸ…ΎοΈ=circ
::β˜‰::c=x-64v=y-64camera(c,v)
for i=0,l do πŸ…ΎοΈ(c+(i*i-c)%l,v+(i-v)%l,0,i%6)end?"웃",x-3,y-2,6
u=r()if(u<.1)add(z,{x=x+l*🐱(l*u),y=y+l*β˜…(l*u)})
b=btn()if(b>0)q=…(b\2%2-b%2,b\8%2-b\4%2)m=🐱(q)n=β˜…(q)x+=m y+=n m=x+m*6n=y+n*6
πŸ…ΎοΈ(m,n,3,9)?""
?p
for e in all(z)do
❎,β–€=x-e.x,y-e.y
a=…(❎,β–€)u=t()/l+r(β–ˆ)e.x+=u*🐱(a)e.y+=u*β˜…(a)?"Λ‡",e.x-3,e.y-2,0
if((❎/5.1)^2+(β–€/5.1)^2<1)stop()
if(((m-e.x)/5)^2+((n-e.y)/5)^2<1)del(z,e)p+=1
end?"⁢1⁢c3",0,0
goto β˜‰--koz

P#148341 2024-05-13 03:39 ( Edited 2024-05-13 03:44)

[ :: Read More :: ]

Bouncy Ball

Cart #bouncyball-3 | 2024-05-14 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
27


v3 2024-05-14:

  • skarrmann hidden palette added
  • increased chance of seeing secret unlockables

"The depressing thing about tennis is that no matter how good I get, I'll never be as good as a wall."
    - Mitch Hedberg

Game Guide

It takes a steady paddle...

The paddle imparts its speed on the ball, so keep it steady or use this to your advantage to control the ball.. if you can keep up with it!

Modifiers

Modifiers will refresh along the back wall every 5 bounces. Some will give you an advantage, others a disadvantage. Be careful what you land on!

Demo Mode

Bouncy Ball includes a self-playing demo mode. Unlock up to 4 CPU demo skill levels by playing!

Thanks to the PICO-8 community!

Big heartfelt thanks to @zep for making this wonderfully fun tool!
Credit for nice smooth circles goes to @2darray: aacirc() is used from Marble Merger.
Thanks to everyone on the BBS and Discord for harboring such an amazing community!

This is my first PICO-8 game release, and my second complete game release overall. I tried desperately to keep it as simple as possible in order to actually bring it to completion. As such, the game is only 4 colors!...

...However, there may or may not be additional palettes included as hidden unlockables within the game...

Suggest a suitable (reasonable contrast) 4-color palette in the comments and I may just include it as a rare unlockable option, along with your name!


High Scores

  1. 49 skarrmann
P#145816 2024-04-05 17:45 ( Edited 2024-05-14 15:36)

[ :: Read More :: ]

This is pretty simple but I thought some devs might find it useful as an easy way to add a minimap to your game. It uses tline to draw a miniature version of the full map area to screen (during your _draw loop):

for i=0,64 do tline(0,32+i,128,32+i,4/8,4/8+i,1) end

The representative pixel is drawn from the center (4/8,4/8) of each sprite, but you can alter this if you want a different selection.

Here's an example of what this looks like in Celeste:

And here's Air Delivery with this line added:

Obviously it can be a bit messy raw, but it's accurate. For your own project, you could put this against a solid background color in your pause menu, for example. And then you might add an indicator for player position ;)

I hope this can be useful out there!

P#142332 2024-03-02 19:38 ( Edited 2024-03-03 02:41)

[ :: Read More :: ]

Shimmerscale

NOW IN GLORIOUS QUADRACOLOR

Consuming 239 chars because I didn't bother to minify further:

cls(13)s=sin
a=12b=4
::_::
t=time()/4
for i=0,36 do 
for j=0,42 do
r=(i+1.4*j)/64
m=12*s(t+r)
x=-8+4*i+3.4*s(t+r-.25)
y=-20+4*j+8*s(r)
if(btn(❎))a=11b=5
if(btn(πŸ…ΎοΈ))a=12b=4
o=a+(i/3+j/3+t*16)%b
line(x,y-m,x+1,y-m+s(t+r+.75),o)
end
end
goto _

Press ❎ to activate CHROMATOSIS:
An experimental bleeding-edge 5-color mode

Feel free to use/modify this effect for your projects!

a is the starting color and b is how many subsequent colors in the palette to use, so you can alter this to use any colors you want using pal({}) and those two variables. Note that the effect relies on not using cls() so this would be best suited to a splash screen or menu, or for use with clip()

*angle also slightly modified for this example

P#140449 2024-01-22 19:12 ( Edited 2024-01-22 21:28)

[ :: Read More :: ]

I've been working on a little tweetcart so that I might have something to actually release while still at work on more ambitious projects.

I was able to get it down to 272 chars. It runs at 60fps.

Edit: Used up the last few characters fixing a bug, refining the decay and adding some slight interactivity. Some chars can probably be reclaimed by combining the loops somehow (and using goto instead) but I'll probably just leave it at this.

It starts slow and continues building over time. Enjoy!

Cart #tc_firedance-2 | 2024-01-09 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
8

P#139821 2024-01-08 16:39 ( Edited 2024-01-31 19:21)