So here's the story.....
Watching this very boring movie with my wife, I browse youtube and come accros this video of a very old game I love to play as a kid on my Commondor 64.
This is the end result in about 2 hours 34 minutes.
Very rough, bugs, but it's kindoff working and NOT finish.
Everything is hardcoded, and only a few variables used... lots of room to expand....
Original Game Video "https://www.youtube.com/watch?v=sG5ERk7wHa8"
// Project: C64_chopper_flight
// Created: 20-11-14
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "C64_chopper_flight" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
#include "game.scene"
#constant KEY_LEFT 37
#constant KEY_UP 38
#constant KEY_RIGHT 39
#constant KEY_DOWN 40
#constant KEY_Q 81
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 )
global wall1id as integer
global hflip as integer
global wallLeftid as integer
global wallrightid as integer
global chopperid as integer
global stepsid as integer
global speed as integer = 10
global peopleid as integer
global stopt as float
global startt as float
global peoplet as float
global peoplesprite as integer = 50
global stopped as integer = 0
global xx as integer
global xx2 as integer
global yy as integer
global waitspawn as integer
global waitspawn2 as integer
global score as integer
global lives as integer
global heartid as integer
global alienid as integer
global aliencount as integer
global alienrnd as integer
global alieny as integer = 800
global alienRndX as integer
wall1id=loadimage("wall1.png")
chopperid =loadimage("chopper.png")
stepsid = loadimage("steps.png")
peopleid = loadimage("people.png")
heartid = loadimage("heart.png")
alienid = loadimage("alien.png")
game_setup()
initscores()
init_game()
do
if gettextexists(game_scores)
settextstring(game_scores,"Score: "+str(score)+" Lives: "+str(lives))
endif
check_collusions()
game_run()
checkkey_inputs()
if GetRawKeyPressed(KEY_Q) = 1
exit
endif
Sync()
loop
function check_end()
dec lives
if lives < 0
Message("Sorry!.. You Loose... Score: "+str(score))
initscores()
endif
endfunction
function check_collusions()
if GetSpriteCollision(5,1) or GetSpriteCollision(5,2) or GetSpriteCollision(5,3) or GetSpriteCollision(5,4)
//deletealltext()
DeleteAllSprites()
init_game()
endif
for a = 10 to 15
if GetSpriteCollision(5,a)
//deletealltext()
DeleteAllSprites()
check_end()
init_game()
endif
next a
for a = 20 to 25
if GetSpriteCollision(5,a)
//deletealltext()
DeleteAllSprites()
check_end()
init_game()
endif
if getspritey(a) < 0
if GetSpriteImageID(a) = heartid
else
score = score - 5
endif
deleteSprite(a)
endif
next a
for a = 40 to 45
if GetSpriteExists(a)
if GetSpriteCollision(5,a)
SetSpriteImage(a,heartid)
score = score + 10
endif
endif
if GetSpriteExists(a)
if getspritey(a) < 0
score = score - 2
deleteSprite(a)
endif
endif
next a
for a = 50 to 55
if GetSpriteExists(a)
if getspritey(a) < 0
score = score - 2
deleteSprite(a)
endif
endif
if GetSpriteExists(a)
if GetSpriteCollision(5,a)
SetSpriteImage(a,heartid)
//deletesprite(a)
score = score + 10
endif
endif
next a
endfunction
function create_alien()
inc aliencount
if aliencount > alienrnd
if moveAlien = 0
if GetSpriteExists(100)
deletesprite(100)
endif
createsprite(100,alienid)
SetSpritePosition(100,alienRndX,alieny)
movealien = 1
endif
endif
if moveAlien = 1
dec alieny,random(5,15)
setspriteposition(100,alienRndX,alieny)
print("alien y "+str(getspritey(100)-10))
print("alien x "+str(getspritex(100)))
if getspritey(100)-10 < -100
alieny=800
deletesprite(100)
aliencount = 0
movealient = 0
alienrnd = random(100,400)
alienRndX = random(250,600)
endif
endif
endfunction
function game_run()
create_alien()
inc waitspawn
if waitspawn > 100
x = random (1,5)
if GetSpriteExists(x+39)
deletesprite(x+39)
createsprite(x+39,peopleid)
SetSpritePosition(x+39,250,getspritey(x+39)-25)
else
createsprite(x+39,peopleid)
SetSpritePosition(x+39,250,getspritey(x+39)-25)
endif
waitspawn = 0
elseif waitspawn > 60
b = random(1,5)
if getspriteexists(x+39)
deletesprite(x+39)
endif
endif
inc waitspawn2
if waitspawn2 > 100
x = random (1,5)
if GetSpriteExists(x+49)
deletesprite(x+49)
createsprite(x+49,peopleid)
SetSpritePosition(x+49,760,getspritey(x+49)-25)
else
createsprite(x+49,peopleid)
SetSpritePosition(x+49,760,getspritey(x+49)-25)
endif
waitspawn2 = 0
elseif waitspawn2 > 60
b = random(1,5)
if getspriteexists(x+49)
deletesprite(x+49)
endif
endif
if stopped = 0
if timer() > stopt
startt = random(3,10)
resettimer()
stopped = 1
endif
SetSpritePosition(1,xx,getspritey(1)-2)
SetSpritePosition(2,xx,getspritey(2)-2)
SetSpritePosition(3,xx2,getspritey(3)-2)
SetSpritePosition(4,xx2,getspritey(4)-2)
for a = 40 to 45
if GetSpriteExists(a)
s1 = getspritey(a)
SetSpritePosition(a,250,getspritey(a-30)-25)
endif
next a
for a = 50 to 55
if GetSpriteExists(a)
s1 = getspritey(a)
SetSpritePosition(a,760,getspritey(a-30)-25)
endif
next a
for a = 10 to 15
s1 = getspritey(a)
SetSpritePosition(a,210,s1-2)
if s1 = 0
SetSpritePosition(a,210,768)
endif
next a
for a = 20 to 25
s1 = getspritey(a)
SetSpritePosition(a,755,s1-2)
if s1 = 0
SetSpritePosition(a,755,768)
endif
next a
if GetSpritey(1) < 0
SetSpritePosition(2,xx,getspritey(1)+GetSpriteHeight(1)+2)
SetSpritePosition(4,xx2,getspritey(3)+GetSpriteHeight(3)+2)
endif
if GetSpritey(2) < 0
SetSpritePosition(1,xx,getspritey(2)+GetSpriteHeight(2)+2)
SetSpritePosition(3,xx2,getspritey(4)+GetSpriteHeight(4)+2)
endif
else
if timer() > startt
stopt = random(3,10)
resettimer()
stopped = 0
endif
endif
endfunction
function checkkey_inputs()
if GetRawKeyState(KEY_LEFT) = 1
setspriteposition(5,getspritex(5)-speed,getspritey(5))
SetSpriteFlip(5,1,0)
hflip = 1
elseif GetRawKeyState(KEY_RIGHT) = 1
setspriteposition(5,getspritex(5)+speed,getspritey(5))
if hflip = 1
SetSpriteFlip(5,0,0)
hflip = 0
endif
elseif GetRawKeyState(KEY_UP) = 1
setspriteposition(5,getspritex(5),getspritey(5)-speed)
elseif GetRawKeyState(KEY_DOWN) = 1
setspriteposition(5,getspritex(5),getspritey(5)+speed)
endif
endfunction
function initscores()
score = 0
lives = 5
endfunction
function init_game()
xx = 10
xx2 = 815
yy = 10
if gettextexists(1)
deletetext(1)
createtext(1,"Score: "+str(score)+" Lives: "+str(lives))
endif
createsprite(1 ,wall1id)
SetSpritePosition(1,xx,yy)
createsprite(2,wall1id)
SetSpritePosition(2,xx,getspritey(1)+GetSpriteHeight(1)+15)
createsprite(3 ,wall1id)
SetSpritePosition(3,xx2,yy)
createsprite(4,wall1id)
SetSpritePosition(4,xx2,getspritey(3)+GetSpriteHeight(3)+15)
SetSpriteFlip(3,1,0)
SetSpriteFlip(4,1,0)
createsprite(5,chopperid)
SetSpritePosition(5,450,400)
sy = 100
for a = 10 to 15
createsprite(a,stepsid)
SetSpritePosition(a,210,sy)
sy = sY + 130
next a
sy = 100
for a = 20 to 25
createsprite(a,stepsid)
SetSpritePosition(a,755,sy)
SetSpriteFlip(a,1,0)
sy = sY + 130
next a
yy = 10
resettimer()
stopt = random(3,20)
peoplet = random(1,5)
alienrnd = random(100,300)
alienRndX = random(200,600)
endfunction
Breakin, expand it, use it, do whatever you find usefull... BUT PLEASE SHARE ON THE FORUM
Just another proof how easy it can be to do a very basic game in AppGameKit, and AGKS.
Enjoy
Danie!