Here is the first game I ever made. I just noticed that it is short enough to be a 20-liner, so here it is:
Compressed:
hide mouse : cls rgb(0,0,0) : Center Text 320,240,"Loading..." : Load image "ablast1.bmp",1 : Load image "ablast2.bmp",2 : Load image "ablast3.bmp",3 : Load image "blue laser.bmp",4 : Load image "green laser.bmp",5 : Load image "pink laser.bmp",6 : Load image "red laser.bmp",7 : Load image "white laser.bmp",8 : Load image "explode1.bmp",10 : Load image "explode2.bmp",11 : Load music "torrent.mid",1 : Load sound "edestroy.wav", 1 : Load sound "getready.wav",2 : xpos = 10 : : ypos = 190 : image = 1 : direction = 3 : breakspeed = 5 : speed = 0 : lasercreation = 50 : maxlasers = 50 : lasercounter = 0
lasers = 0 : explodespeed = 0 : paused = 0 : explodeanim = 10 : DIM laser(50,4) : sync on : Randomize Timer : cls : Set cursor 200,240 : Input "Enter Time (300-Easy, 500-Hard):",input$ : Time = Val(Input$) : Cls : Center text 320,240,"Get Ready..." : play sound 2 : sleep 3000 : cls rgb(0,0,0) : Loop music 1 : starttime = Timer() : Do : If lasercounter > lasercreation and lasers < maxlasers and paused = 0 : lasercounter = 0 : makelaser(lasers) : lasers = lasers + 1 : endif : For I = 1 to lasers
If paused = 0 : laser(I,1) = laser(I,1) - laser(I,4) : endif : If laser(I,1) < -48 : makelaser(I) : endif : sprite I+1, laser(I,1), laser(I,2), laser(I,3) : If sprite collision(1,I) = 1 and I > 1 : sprite lasers + 2, xpos - 40, ypos - 40, explodeanim : If paused = 0 : Play sound 1 : endif : paused = 1 : endif : Next I : IF Leftkey() = 1 and paused = 0 : direction = 2 : speed = breakspeed : endif : If rightkey() = 1 and paused = 0 : direction = 3 : speed = breakspeed : endif : If upkey() = 1 and paused = 0 : direction = 1
speed = breakspeed : endif : If downkey() = 1 and paused = 0 : direction = 4 : speed = breakspeed : endif : If speed > 0 : If xpos < 1 : speed = 0 : xpos = xpos + 1 : Endif : If xpos > 639 - sprite width(1) : speed = 0 : xpos = xpos - 1 : Endif : If ypos < 1 : speed = 0 : ypos = ypos + 1 : Endif : If ypos > 479 - sprite height(1) : speed = 0 : ypos = ypos - 1 : endif : If direction = 1 : ypos = ypos - speed
speed = speed - 2 : endif : If direction = 2 and paused = 0 : xpos = xpos - speed : speed = speed - 2 : endif : If direction = 3 and paused = 0 : xpos = xpos + speed : speed = speed - 2 : endif : If direction = 4 and paused = 0 : ypos = ypos + speed : speed = speed - 2 : endif : Endif : image = image + 1 : If image > 3 : image = 1 : endif : sprite 1,xpos,ypos,image : lasercounter = lasercounter + 1 : If paused = 1 : explodespeed = explodespeed + 1 : endif : If explodespeed = 7
explodeanim = explodeanim + 1 : endif : If explodespeed = 30 : losegame(lasers) : endif : sync : cls : set cursor 0,0 : Print "Time Left: " + str$( int(Time - ((timer() - starttime)/100))) : If timer() - starttime > time*100 : sleep 1000 : wingame(lasers) : endif : Loop
Function makelaser(number) : laser(number,1) = 640 : laser(number,2) = rnd(476) : laser(number,3) = rnd(4)+4 : laser(number,4) = rnd(6)+4 : Endfunction : Function losegame(numlasers) : stop music 1 : Destroy_sprites(numlasers) : cls : sync : Center Text 320,240,"You lose!" : sleep 3000 : end : Endfunction : Function wingame(numlasers) : stop music 1 : Destroy_Sprites(numlasers) : cls : sync : Center Text 320,240,"You win!" : sleep 3000 : end : Endfunction : Function Destroy_Sprites(numlasers)
For I = 1 to numlasers+2 : If sprite exist(I) = 1 : delete sprite I : endif : next I : Endfunction
Uncompressed:
`****************************************************************
`*************************~LASER Assault!~***********************
`****************************************************************
`******************************By UFO****************************
`****************************************************************
hide mouse
cls rgb(0,0,0)
`sprites: 1-player, 2/51-lasers,
Center Text 320,240,"Loading..."
`Loading stuff
Load image "ablast1.bmp",1
Load image "ablast2.bmp",2
Load image "ablast3.bmp",3
Load image "blue laser.bmp",4
Load image "green laser.bmp",5
Load image "pink laser.bmp",6
Load image "red laser.bmp",7
Load image "white laser.bmp",8
Load image "explode1.bmp",10
Load image "explode2.bmp",11
Load music "torrent.mid",1
Load sound "edestroy.wav", 1
Load sound "getready.wav",2
`VARIABLES
xpos = 10 :`x position of player's ship
ypos = 190 : `y position of player's ship
image = 1 : `Frame number of the animation of the player's ship
direction = 3 : `Direction of player's ship - used for slowing down effect
breakspeed = 5 : `Speed of which the player's ship slows down - lower = faster - used in slowing down effect
speed = 0 : `Speed of player's ship - used in slowing down effect
lasercreation = 50 : `speed of which the lasers are created
maxlasers = 50 : `maximum amount of lasers on the screen at a time
lasercounter = 0 : `counter used with lasercreation for speed of making the lasers
lasers = 0 : `amound of lasers on the screen
explodespeed = 0 : `counter for how long the frames of the explosion animation last
paused = 0 : `If it is one, the lasers and other game objects freeze.
explodeanim = 10 : `Frame of the explosion animation
DIM laser(50,4) : `Laser stats - xpos,ypos,speed,color
sync on
Randomize Timer
`Getready animation and music
cls
Set cursor 200,240
Input "Enter Time (300-Easy, 500-Hard):",input$
Time = Val(Input$)
Cls
Center text 320,240,"Get Ready..."
play sound 2
sleep 3000
cls rgb(0,0,0)
Loop music 1
starttime = Timer()
`MAIN LOOP!
Do
`CREATES THE LASERS!
If lasercounter > lasercreation and lasers < maxlasers and paused = 0
lasercounter = 0
makelaser(lasers)
lasers = lasers + 1
endif
`LASER STUFF!
For I = 1 to lasers
`MOVES THE LASER!
If paused = 0 then laser(I,1) = laser(I,1) - laser(I,4)
`WARPS THE LASER!
If laser(I,1) < -48 then makelaser(I)
`DRAWS LASER
sprite I+1, laser(I,1), laser(I,2), laser(I,3)
`CHECKS COLLISION
If sprite collision(1,I) = 1 and I > 1
sprite lasers + 2, xpos - 40, ypos - 40, explodeanim
If paused = 0 then Play sound 1
paused = 1
endif
Next I
`CONTROLLS!
IF Leftkey() = 1 and paused = 0
direction = 2 : speed = breakspeed
endif
If rightkey() = 1 and paused = 0
direction = 3 : speed = breakspeed
endif
If upkey() = 1 and paused = 0
direction = 1 : speed = breakspeed
endif
If downkey() = 1 and paused = 0
direction = 4 : speed = breakspeed
endif
`KEEPING THE SHIP WITHIN THE SCREEN!
If speed > 0
If xpos < 1
speed = 0 : xpos = xpos + 1
Endif
If xpos > 639 - sprite width(1)
speed = 0 : xpos = xpos - 1
Endif
If ypos < 1
speed = 0 : ypos = ypos + 1
Endif
If ypos > 479 - sprite height(1)
speed = 0 : ypos = ypos - 1
endif
`MOVING THE SHIP! and paused = 0
If direction = 1
ypos = ypos - speed : speed = speed - 2
endif
If direction = 2 and paused = 0
xpos = xpos - speed : speed = speed - 2
endif
If direction = 3 and paused = 0
xpos = xpos + speed : speed = speed - 2
endif
If direction = 4 and paused = 0
ypos = ypos + speed : speed = speed - 2
endif
Endif
`DRAWING THE SHIP AND IT'S ANIMATION!
image = image + 1 : If image > 3 then image = 1
sprite 1,xpos,ypos,image
lasercounter = lasercounter + 1
If paused = 1 then explodespeed = explodespeed + 1
If explodespeed = 7 then explodeanim = explodeanim + 1
If explodespeed = 30
losegame(lasers)
endif
sync
cls
set cursor 0,0
Print "Time Left: " + str$( int(Time - ((timer() - starttime)/100)))
If timer() - starttime > time*100
sleep 1000
wingame(lasers)
endif
`!!!
Loop
Function makelaser(number)
laser(number,1) = 640
laser(number,2) = rnd(476)
laser(number,3) = rnd(4)+4
laser(number,4) = rnd(6)+4
Endfunction
Function losegame(numlasers)
stop music 1
Destroy_sprites(numlasers)
cls
sync
Center Text 320,240,"You lose!"
sleep 3000
end
Endfunction
Function wingame(numlasers)
stop music 1
Destroy_Sprites(numlasers)
cls
sync
Center Text 320,240,"You win!"
sleep 3000
end
Endfunction
Function Destroy_Sprites(numlasers)
For I = 1 to numlasers+2
If sprite exist(I) = 1
delete sprite I
endif
next I
Endfunction
Media's Attached and the Standalone Exe is in the next post.