Marcus,
Very nice! I'm looking forward to playing with naalaa on my Ubuntu 16.04 64 bit Linux laptop.
' ==============================================================================
' Bouncing balls.
' ==============================================================================
' This library helps us maintain constant fps.
import "Speed.lib"
' Turn of automatic redraw.
set redraw off
' Load a ball image.
load image 1, "assets/ball.png"
' Ground position.
groundY = 400
' Create a couple of ball objects, as many as fits the width of the window.
balls?[width(primary)/width(1)]
' Initialize their properties.
for i = 0 to sizeof(balls) - 1
' Set position, a wavey curve above ground.
balls[i].x = i*width(1)
balls[i].y# = float(groundY) - 150.0 + sin(float(i*45))*75.0
' Set vertical speed.
balls[i].dy# = 0.0
next
do
' Update balls.
for i = 0 to sizeof(balls) - 1
' Increase speed, gravity.
balls[i].dy# = balls[i].dy# + 0.1
' Update position.
balls[i].y# = balls[i].y# + balls[i].dy#
' Bounce?
if balls[i].y# > float(groundY - height(1))
balls[i].y# = float(groundY - height(1))
balls[i].dy# = -6.0
endif
next
' Clear screen.
set color 0, 0, 0
cls
' Draw ground.
set color 255, 255, 255
draw line 0, groundY, width(primary), groundY
' Draw the balls.
for i = 0 to sizeof(balls) - 1
draw image 1, balls[i].x, int(balls[i].y#)
next
' Update the window.
redraw
' Wait enough for 60 fps.
_SPD_HoldFrame 60
until keydown(27)