02-05-2024, 12:51 AM
Our world is unique, one earth but it has opposite weather between the northern and southern hemisphere
Sometimes, I just entertain myself with "the falling snow" code below ...
Sometimes, I just entertain myself with "the falling snow" code below ...
Code:
' Sources :
' The falling snow is inspired from the moving stars in Blastemroids (Naalaa 6) by Marcus
'----------------
' INITIALIZATION
'----------------=
w = 640
h = 300
snow = []
hill = []
myfont = []
#win32
set window "Snow",w,h,false
set redraw off
'initial value
snow.dx = 0
snow.dy = 0
snow.img = 0
myfont.img = 0
myfont.size = 50
'create a snow image from ellipses
create image snow.img, w,h
set image snow.img
set color 100,100, 100 'gray background
cls
for i = 0 to 500
snow.radius = rnd(4)
set color 255, 255, 255, rnd(256)
draw ellipse rnd(w),rnd(h),snow.radius,snow.radius,1
next
set image primary
'load assets
hill.img = loadimage ("data_snow/landscape.png")
myfont.img = createfont("Arial", myfont.size, 0,0,0,0)'name,size,bold,italic,underlined,smoothed
'--------------
' MAIN PROGRAM
'--------------
do
set color 0,0,0;cls; set color 255,255,255'white
'snow movement 1 pixel at a time diagonally, use 4 images as continuity
snow.dx = (snow.dx + 1)%w
snow.dy = (snow.dy + 1)%h
draw image snow.img, -w + snow.dx , snow.dy
draw image snow.img, 0 + snow.dx , snow.dy
draw image snow.img, -w + snow.dx , snow.dy - h
draw image snow.img, 0 + snow.dx , snow.dy - h
'draw a static hill
draw image hill.img,0,(0.625*h)
set font myfont.img; set caret w/2,50; center "It's snowy..."
wait 10
redraw
until keydown(KEY_ESCAPE)