rem Sprites - OpenDBC tutorial (DarkBASIC Classic) rem Media: sea.bmp, scooter.bmp and rock.bmp from examples/dbc/tutorials/sprite sync on : sync rate 60 w = screen width() : h = screen height() load bitmap "sea.bmp", 1 set current bitmap 0 load image "scooter.bmp", 1 load image "rock.bmp", 2 rem Sprite 1 is the scooter; black pixels are transparent x# = w / 2 sprite 1, x#, h - 90, 1 rem Sprite 2 is a rock falling from the top rx = rnd(w - 48) : ry# = -50 sprite 2, rx, ry#, 2 hits = 0 do rem Draw the sea, then the sprites appear on top copy bitmap 1, 0 rem Steer with the arrow keys, or follow the rock on your own if leftkey() = 1 then x# = x# - 5 if rightkey() = 1 then x# = x# + 5 if leftkey() + rightkey() = 0 then x# = x# + (rx - x#) * 0.02 sprite 1, x#, h - 90, 1 ry# = ry# + 4 if ry# > h then ry# = -50 : rx = rnd(w - 48) sprite 2, rx, ry#, 2 rem SPRITE HIT is 1 on the first frame two sprites touch if sprite hit(1, 2) > 0 then hits = hits + 1 text 10, 10, "Hits: " + str$(hits) sync loop