Skip to content

Instantly share code, notes, and snippets.

@appblue
Created August 30, 2023 23:18
Show Gist options
  • Save appblue/b1e2a46396e3f8749abae314e6887664 to your computer and use it in GitHub Desktop.
Save appblue/b1e2a46396e3f8749abae314e6887664 to your computer and use it in GitHub Desktop.
Daric Sample Code
option base 1
if @main then
mode -1, -1, windowed or banked
sprites()
endif
def sprites()
spriterenderpoint 0
bankedon
w = screenwidth(): h = screenheight()
' load assets
bg = loadsprite("assets/background.png")
ship = loadsprite("assets/battleship-top.png")
explosion = loadsprite("assets/exp_type_c.png")
' load music and start playback
music = loadmusic("assets/2nd_pm.s3m")
musicvolume(1.0)
playmusic(music, 0)
ex = rnd(w): ey = rnd(h)
sw = 128: sh = 128: sprites = 64
dim sx :int[sprites]
dim sy :int[sprites]
dim sdx :int[sprites]
dim sdy :int[sprites]
' set initial values to all tables
for i = 1 to sprites
sx[i] = rnd(w): sy[i] = rnd(h): sdx[i] = 1: sdy[i] = 1
next
j = 0
for loop=0.0 to 5000.0 step 0.25
cls
let bgx = screenwidth()/2 + 128 * sin(6.28 * loop / 150)
let bgy = screenheight()/2 + 128 * sin(6.28 * loop / 100)
drawsprite bg, 0, bgx, bgy, 0, 1
for i = 1 to sprites
let rot = 0.6 * sin(6.28 * loop / 32) + 1.5
drawsprite ship, 0, sx[i], sy[i], loop*2, rot
rem move the sprites
sx[i] = sx[i] + sdx[i]
sy[i] = sy[i] + sdy[i]
rem check whether at edge
if sx[i] < 0 sdx[i] = 1
if sx[i] > w-sw-1 sdx[i] = -1
if sy[i] < 0 sdy[i] = 1
if sy[i] > h-sh-1 sdy[i] = -1
next
' explosion (sprite offset)
' line 0,screenheight()/2,screenwidth(),screenheight()/2
' line screenwidth()/2,0,screenwidth()/2,screenheight()
drawpartsprite explosion, 0, ex, ey, 0, 1, j*256, 0, 256, 256
j = j + 1
if j=48 then
ex = rnd(w): ey = rnd(h)
j=0
endif
flip
if waitkey(0) then
deletesprite ship:deletesprite bg
bankedoff
return
endif
next
deletesprite ship:deletesprite bg
bankedoff
stopmusic(500)
enddef
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment