ctmatthews

Indie game developer

a trans woman in the UK making 2D action games about ducks:

Ducky's Delivery Service (Steam/itch/Switch)

Chessplosion (Steam/itch)


i mostly post on my Blog / Newsletter / Patreon


i play fighting games! i won Evo in 2021.


pfp/header by NomnomNami


πŸ“° Blog
ctmatthews.com/blog
πŸ’Œ Newsletter
ctmatthews.com/newsletter
βœ‰οΈ Contact (email/DM)
ctmatthews.com/contact
πŸ’» itch.io
ctmatthews.itch.io/
🐣 Patreon
patreon.com/ctmatthews
πŸ–ΌοΈ pfp/header by NomnomNami
nomnomnami.com/

nomnomnami
@nomnomnami

SnowBlossom() is a really cool function that draws a bunch of sprites to the screen and moves them around according to whatever numbers you tell it to. the effect is named for falling snow or cherryblossoms... but in Packed to the Gills, i used it to make fish swim by and bubbles rise up on the title screen (gif above).

it's relatively simple to add for how rewarding the result feels!! that's why i wanted to share it, even though it's more of an extra polish thing than something you should always do... (obviously skip it if it doesn't suit your project!)

anyway if you JUST want to add simple sprites falling from the top of the screen to your game, there's a VNConf talk by Justinn that demonstrates exactly that! the whole talk is full of extremely cool stuff, so i highly recommend it (link is timestamped to the SnowBlossom() part)

but if you wanna see how i made the title screen above, read on!!


first, the fishies. i have an image, sardine, that is just a fish facing left like this 🐟

let's plug him in...

image sardines swimmin = SnowBlossom("sardine",
    count=15, border=120,
    xspeed=(-300,-400), yspeed=(10, 20),
    start=5, horizontal=True)

all these properties are explained in the documentation, but i'll go over them quickly in plain language.

~ THE PROPERTIES ZONE ~
  • count is about how many there are onscreen at a time.
  • border is how far from the edge until it disappears (i think this fish is ~120px wide... change the number to what works for your sprite!)
  • xspeed is making it move to the left at a random value between those two numbers.
  • yspeed is the same, but for vertical movement.
  • making start a higher number means the 15 fish won't all spawn in at once.
  • horizontal means it's spawning from the side of the screen instead of the top or bottom!

sorry, i know i said this was easy to add... honestly, it's fun to play with the numbers and reload to see how it changes. there's another property i didn't even use here called fast that will spawn sprites in from the middle of the screen too! but you can exclude any of these properties you want--i just happened to need to use them all to make my fishies swim the way i wanted.

now to show them on the title screen. all we need to do is open up screens.rpy and look for main_menu()...

screen main_menu():

    tag menu

    add gui.main_menu_background
    add "sardines swimmin" ##right here!

make sure to add it AFTER the background image!!! otherwise it will show underneath it, and you'll wonder where it is... (i have accidentally shown screen elements under background images before and felt like an idiot when i realized why nothing was changing lol)

ok, next, THE BUBBLES! i have one bubble.png that i'm showing at two different zoom levels to add a little depth/variety. i'm also making them 25% opacity so you can see through them when they overlap... (you don't need to do that part if it doesn't make sense for whatever your sprites are)

image bubble:
    "images/bubble.png"
    alpha .25
image smallbubble:
    "images/bubble.png"
    alpha .25 zoom .5 ##the .5 here means 50% smaller

now to SNOWBLOSSOM-IZE THEM

image midbubbles = SnowBlossom("bubble",
    count=10, border=40,
    xspeed=(-10,10), yspeed=(-100,-200), start=5)

image smallbubbles = SnowBlossom("smallbubble",
    count=20, border=30,
    xspeed=(-10,10), yspeed=(-100,-200), start=5)

they're basically the same except for the count and border since i want more small bubbles on screen, and being smaller means it's okay to despawn them closer to the edge. i changed the xspeed from those big numbers the sardines used, because i only want them to drift slightly left/right. yspeed is higher, and negative because it's rising up!

we could add both sets of bubbles to the main_menu() screen right now, but... well, there's no reason to show them separately. so let's combine them into one displayable.

image bubbles:
    contains:
        "midbubbles"
    contains:
        "smallbubbles"

easy! now we just need to put the newly defined "bubbles" displayable between our bg and the sardines:

screen main_menu():

    tag menu

    add gui.main_menu_background
    add "bubbles"
    add "sardines swimmin"

voila :eggbug-uwu: that's all it takes. i hope you have fun writing cool SnowBlossoms too!


You must log in to comment.

in reply to @nomnomnami's post:

this is SO cool! i am super bad at coding such that even reading documentation and tutorials for renpy is kind of overwhelming lol, so i really appreciate your renpy tips and how you break stuff down.