[bb] Retro Platformer Remake by Pakz [ 5 months ago ]

Started by BlitzBot, June 29, 2017, 00:28:39

Previous topic - Next topic

BlitzBot

Title : Retro Platformer Remake
Author : Pakz
Posted : 5 months ago

Description :

I made this years ago. It is a remake of one level of a game I played on the Amiga Computer called Adams Family Values. It has no graphics only rectangles and text.
The level afaicr is a 1:1 remake of one of the levels from the original game.


Code :
Code (blitzbasic) Select
Graphics 640,480,16,2
SetBuffer BackBuffer()

Dim map(270,15)

Type fps
Field fps,fpstimer,fpscounter
End Type
Global fps.fps = New fps
Type font
Field money
Field normal
Field hud
End Type
Global font.font = New font
fontmoney = LoadFont("verdana.ttf",44)
font
ormal = LoadFont("Verdana.ttf",12)
fonthud = LoadFont("verdana.ttf",32,True)
SetFont font
ormal
Type game
Field back
Field offx,offy,cx,cy
; demo
Field sdir,editor
End Type
Global g.game = New game
gack = CreateImage(640,480)
Type player
Field x#,y#,w,h,ow,oh,duckwidth,duckheight
Field jump,fallspeed#,fall
Field direction,slide,slidespeed#
Field state ; stand,duck
Field money,cheat,lives,hits
Field blinking,blinkingdelay,blink,blinktimer
End Type
Global p.player = New player

Type ai
Field x#,y#,velx#,vely#,w,h
Field kind
Field firedelay,jumpdelay
Field jump,fallspeed#
End Type

Type bullet
Field x#,y#,w,h
Field state
Field timer1
Field velx#,vely#
Field timeout
End Type

Type rot
Field ang#
Field Sine#
Field angdir,timedelay,cnt
Field chainx#[3],chainy#[3]
Field ballx#,bally#
End Type

Type money
Field x#,y#,fallspeed#
End Type

Type gfx
Field ball,smallball
End Type
Global gfx.gfx = New gfx

inigfx
inigame


While KeyDown(1) = False
;Cls
updateai
updatebullets
updaterot
gravity
playeraikill()
aiplayerkill()
spikesplayerkill()
bulletsplayerkill
rotplayerkill
playerblinkingeffect()
updatemoney
playermoneycollision
playercontrols
playerslide
mapscroll


SetBuffer ImageBuffer(gack)
Cls
drawbullets
drawmoney
drawrot
drawlevel

drawai
drawplayer
SetBuffer BackBuffer()
DrawBlock gack,-32,0
drawhud()
movemlevel()
If shiftdown() = True Then geditor = True Else geditor = False
Color 255,0,0
; Text 0,20,px-maprealx()
; Text 0,0,rectmapcollision(MouseX()+maprealx(),MouseY()+maprealy(),2,2,0,0)
; Text GraphicsWidth()-128,0,myfps()
; Text 256,0,rectmapcollision(px,py,48,80,0,0)
; Text 400,0,pfall + " ?: " + pjump

If MouseDown(1) = True Then px = MouseX()+maprealx() : py = MouseY()+maprealy()
Flip
Wend
End

Function inigame()
;px = 3180
freegame
px = 90
py = 128+48
pw = 48 : pow = 48 : pduckwidth = 48
ph = 80 : poh = 80 : pduckheight = 32
phits = 3
plives = 1
plinkingdelay = MilliSecs() + 3000
plinktimer = 50
plink = True

gcx = 0;33;;88
goffx = 0
goffy = 0
geditor = False
readlevel(1)
End Function


Function rotplayerkill()
If plinkingdelay > MilliSecs() Then Return
If pcheat = True Then Return
For this.rot = Each rot
If pstate = 1 Then
If ImageRectOverlap(gfxall,thischainx[3],thischainy[3],px,py+(80-32),pw,ph) = True
playerdecreasehit
End If
Else
If ImageRectOverlap(gfxall,thischainx[3],thischainy[3],px,py,pw,ph) = True
playerdecreasehit
End If
End If
Next
End Function

Function updaterot()
For this.rot = Each rot
add=0
thissine = thissine + 2
mth=90*Sin(thissine)
For a=0 To 3
angle=(mth)
thischainx#[a] = thisallx+((add)*Sin(angle))
thischainy#[a] = thisally+((add)*Cos(angle))
add=add+32
If a=2 Then add=add+16
Next


Next
End Function

Function drawrot()
For this.rot = Each rot
Color 0,0,255
MidHandle gfxsmallball
For i=0 To 2
DrawImage gfxsmallball,thischainx[i]-maprealx(),thischainy[i]-maprealy()
Next
MidHandle gfxall
DrawImage gfxall,thischainx[3]-maprealx(),thischainy[3]-maprealy()
Next
End Function

Function playerblinkingeffect()
If plinkingdelay > MilliSecs() Then
If plinktimer < MilliSecs() Then
If plink = True Then plink = False Else plink = True
plinktimer = MilliSecs() + 50
End If
Else
plink = True
End If
End Function

Function drawhud()
; hits
cnt = 0
For y=100 To 0 Step -34
If phits > cnt Then drawlifeimage(32,y)
cnt = cnt + 1
Next
;
; lives
SetFont fonthud
Color 155,155,155
Text 10,GraphicsHeight()-128,"Lives"
Text 32,GraphicsHeight()-108,playerlives()
; money
Color 155,155,155
drawmoneyimage(32,GraphicsHeight()-70)
SetFont fonthud
Text 32,GraphicsHeight()-42,playermoney()
SetFont font
ormal
End Function

Function inirot(x,y)
this.rot = New rot
thisang = 90
thisallx = x
thisally = y+48
End Function

Function playermoneycollision()
For this.money = Each money
If RectsOverlap(px,py,pw,ph,thisx,thisy,32,32) = True Then
pmoney = pmoney + 1
Delete this
End If
Next
End Function

Function inimoney(x,y)
this.money = New money
thisx = x
thisy = y
thisfallspeed = Rnd(-1,0)
End Function

Function updatemoney()
For this.money = Each money
thisy = thisy - thisfallspeed
thisfallspeed = thisfallspeed + .09
If thisfallspeed > 1 Then
thisfallspeed = -1
thisy = thisy/32*32
End If
Next
End Function

Function drawmoney()
For this.money = Each money
drawmoneyimage(thisx-maprealx(),thisy-maprealy())
Next
End Function

Function spikesplayerkill()
If pcheat = True Then Return
If plinkingdelay > MilliSecs() Then Return
x1 = px / 32
y1 = (py+64) / 32
If RectsOverlap(x1,y1,1,1,0,0,170,15) = True Then
If map(x1,y1) = 2 Then playerdecreasehit
End If
End Function

Function playeraikill()
If pfall = True Then
For this.ai = Each ai
If RectsOverlap(px,py,48,80,thisx,thisy,thisw,thish) = True Then
Delete this
End If
Next
End If
End Function

Function playerslide()
If pslide = True
; pstate = 0
If pjump = True Then pslide = False : Return
If pfall = True Then pslide = False : Return
Select pdirection
Case 0
If playerright() = False
If pmcollision(pslidespeed,0) = False Then
px = px + pslidespeed
pslidespeed = pslidespeed - .1
Else
px = px/32*32
pslide = False
pslidespeed = 0
End If
End If
Case 1
If playerleft() = False
If pmcollision(-pslidespeed,0) = False
px = px - pslidespeed
pslidespeed = pslidespeed - .1
Else
px = px/32*32
pslide = False
pslidespeed = 0
End If
End If
End Select
End If
If pslidespeed < 0 Then pslide = False
End Function

Function mapscroll()
x = px - maprealx()
;
If playerright() = False And playerleft() = False
If pslide = True Then
Select pdirection
Case 0
For i=0 To pslidespeed-1
scrolllevel(0)
Next
Case 1
For i=0 To pslidespeed-1
scrolllevel(1)
Next

End Select
End If
End If
;
If x+40> GraphicsWidth() / 2 And playerright() = True Then
If gcx < 70*2-20
scrolllevel(0):scrolllevel(0):scrolllevel(0):scrolllevel(0)
End If
End If
If x-40< GraphicsWidth() / 2 And playerleft() = True Then
If gcx > 0
scrolllevel(1):scrolllevel(1):scrolllevel(1):scrolllevel(1)
End If
End If
End Function



Function playercontrols()
; pstate=0
pw = pow
ph = poh
If playerright() = True Then
If pmcollision(4,0) = False Then
pdirection  = 0
pslide = True
pslidespeed = 2
px=px+4
End If
End If
If playerleft() = True Then
If pmcollision(-4,0) = False Then
pdirection = 1
pslide = True
pslidespeed = 2

px=px-4
End If
EndIf
If KeyDown(200) = True Or KeyDown(57) = True
If pfall = False And pjump = False Then
pjump = True
pfallspeed = -11.5
End If
End If
If playerduck() = True Then
If pjump = False And pfall = False Then
pstate = 1
pw = pduckwidth
ph = pduckheight
End If
Else
pstate = 0
End If
End Function

Function gravity()
If pjump = True And pmcollision(0,pfallspeed) = True Then
pfall = True
pjump = False
pfallspeed = 2
End If
If pmcollision(0,2) = False And pfall = False And pjump = False Then
pfall = True
pjump = True
pfallspeed = 2
End If
If pjump = True Or pfall = True Then
If pfallspeed > 0 Then pfall = True
pfallspeed = pfallspeed + .4
py = py + pfallspeed
For i=1 To pfallspeed
If pmcollision(0,i) = True Then
While pmcollision(0,i) = True
py=py - 1
Wend
pfall = False
pjump = False
Exit
End If
Next
EndIf
End Function

Function bulletsplayerkill()
If pcheat = True Then Return
If plinkingdelay > MilliSecs() Then Return
For this.bullet = Each bullet
Select pstate
Case 0
If RectsOverlap(px,py,pw,ph,thisx,thisy,thisw,thish) = True Then
playerdecreasehit
End If
Case 1
If RectsOverlap(px,py,pw,ph,thisx,thisy+(80-32),thisw,thish) = True Then
playerdecreasehit
End If
End Select
Next
End Function

Function updatebullets()
For this.bullet = Each bullet
Select thisstate
Case 0
If this imer1 + 1500 < MilliSecs() Then thisstate = 1
Case 1
thisvelx = thisvelx + .2
If thisvelx > 5 Then thisstate = 2
Case 2
End Select
thisx = thisx + thisvelx
thisy = thisy + thisvely
If this imeout < MilliSecs() Then Delete this
Next
End Function

Function drawbullets()
For this.bullet = Each bullet
Color 255,255,0
Oval thisx-maprealx(),thisy-maprealy(),48,48,True
Next
End Function

Function inibullet(x,y,dir)
this.bullet = New bullet
thisx = x
thisy = y
thisw = 48
thish = 48
this imer1 = MilliSecs()
this imeout = MilliSecs() + 3800
If dir = 0 Then thisvelx = 5
If dir = 1 Then thisvelx = -5
End Function

Function aiplayerkill()
If plinkingdelay > MilliSecs() Then Return
For this.ai = Each ai
If RectsOverlap(px,py,pw,ph,thisx,thisy,thisw,thish) = True Then
playerdecreasehit()
End If
Next
End Function

Function updateai()
For this.ai = Each ai
Select thiskind
Case 0
If thisjumpdelay < MilliSecs() Then
thisjump = True
thisfallspeed = -4
thisjumpdelay = MilliSecs() + 4800*2
End If
If thisfiredelay < MilliSecs() Then
inibullet(thisx,thisy,1)
thisfiredelay = MilliSecs() + 4800
End If
jumpai(this)
Case 1
thisx = thisx + thisvelx
If rectmapcollision(thisx,thisy,48,64,thisvelx,0) = True Then
thisvelx = - thisvelx
End If
End Select
Next
End Function
Function jumpai(this.ai)
If thisjump = False Then Return
thisy = thisy + thisfallspeed
thisfallspeed = thisfallspeed + .1
For i=0 To thisfallspeed
If rectmapcollision(thisx,thisy,48,48,0,i) = True Then
thisy = thisy/32*32-4
thisjump = False
Exit
End If
Next
End Function

Function drawai()
For this.ai = Each ai
Select thiskind
Case 0
Color 255,0,0
Rect thisx-maprealx(),thisy-maprealy(),48,48,True
Case 1
Color 255,0,0
Rect thisx-maprealx(),thisy-maprealy(),48,64,True
End Select
Next
End Function

Function iniai(x,y,kind)
this.ai = New ai
thisx = x
thisy = y
Select kind
Case 0
thisw = 48
thish = 48
thiskind = 0
thisfiredelay = MilliSecs() + 200
thisjumpdelay = MilliSecs() + 4800
Case 1
thisw = 48
thish = 64
thiskind = 1
thisvelx = -1.7
End Select
End Function

Function movemlevel()
If geditor = True Then
If KeyDown(205) = True Then scrolllevel(0):scrolllevel(0):scrolllevel(0):scrolllevel(0)
If KeyDown(203) = True Then scrolllevel(1):scrolllevel(1):scrolllevel(1):scrolllevel(1)
End If
End Function

Function scrolllevel(num)
Select num
Case 0 ; right
goffx = goffx - 1
If goffx < 0 Then goffx = 31 : gcx = gcx + 1
Case 1
goffx = goffx + 1
If goffx > 31 Then goffx = 0 : gcx = gcx - 1
End Select
End Function

Function drawplayer()
If plink= False Then Return
Select pstate
Case 0 ; stand
Color 0,0,255
Rect px-maprealx(),py-maprealy(),pow,poh,True
Case 1 ; duck
Color 0,0,255
Rect px-maprealx(),py+48-maprealy(),pduckwidth,pduckheight
End Select
End Function

Function drawlevel()
For y=0 To 14
For x=0 To 20
If RectsOverlap((gcx)+x,(gcy)+y,1,1,0,0,160,15) = True Then
Select map(x+gcx,y+gcy)
Case 1
Color 255,255,255
Rect (x*32)+goffx,(y*32)+goffy,32,32,True
Case 2
x1 = (x*32)+goffx
y1 = (y*32)+goffy
Color 255,255,255
Line x1,y1+32,x1+16,y1
Line x1+16,y1,x1+32,y1+32
End Select

End If
Next:Next
End Function

Function readlevel(level)
;
Restore level1suba
For y=0 To 14
For x=0 To 69
Read a
Select a
Case 1
map(x,y) = a
Case 2 ; ai - shooter
iniai(x*32,y*32-(48-32),0)
Case 3 ; ai - walker
iniai(x*32,y*32-32,1)
Case 4 ; rotating thing
inirot(x*32,y*32-32)
Case 5 ; spikes
map(x,y) = 2
Case 6 ; money
inimoney(x*32,y*32)
End Select
Next:Next
Restore level1subb
For y=0 To 14
For x=0 To 69
x1 = x + 69
y1 = y
Read a
Select a
Case 1
map(x1,y1) = a
Case 2 ; ai - shooter
iniai(x1*32,y1*32-(48-32),0)
Case 3 ; ai - wal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,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,5,5,5,1,1,1,1,1,5,5,5,5,1,1,1,1,1,1,1,1,1,1,1,1,1,6,6,6,1
Data 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1



Function maprealx()
a = gcx * 32
b = goffx
Return a-b
End Function
Function maprealy()
a = gcy * 32
b = goffy
Return a-b
End Function

Function rectmapcollision(x,y,w,h,offx,offy)
px = (x) / 32
py = (y) / 32
For y1 = -3 To 4
For x1 = -3 To 3
If RectsOverlap(px+x1,py+y1,1,1,0,0,70*2,15) = True Then
If map(px+x1,py+y1) = 1 Then
;Color 0,250,0
;Rect (px+x1)*32-maprealx(),(py+y1)*32-maprealy(),32,32,False
If RectsOverlap(x+offx,y+offy,w,h,(px+x1)*32,(py+y1)*32,32,32) = True Then
Return True
End If
End If
End If
Next:Next
End Function

Function pmcollision(offx,offy)
Select pstate
Case 0:Return rectmapcollision(px,py,48,80,offx,offy)
Case 1:Return rectmapcollision(px,py,48,80,offx,offy)
End Select
End Function

Function myfps()
fpsfpscounter = fpsfpscounter + 1
If fpsfpstimer < MilliSecs() Then
fpsfpstimer = MilliSecs() + 1000
fpsfps = fpsfpscounter
fpsfpscounter = 0
End If
Return fpsfps
End Function

Function shiftdown()
If KeyDown(42) = True Then Return True
If KeyDown(54) = True Then Return True
End Function
Function playerright()
If KeyDown(205) = True Then Return True
End Function
Function playerleft()
If KeyDown(203) = True Then Return True
End Function
Function playerduck()
If KeyDown(208) = True Then Return True
End Function

Function playermoney$()
If Len(pmoney) = 1 Then Return "0"+pmoney Else Return pmoney
End Function
Function playerlives$()
If Len(plives) = 1 Then Return "0"+plives Else Return plives
End Function

Function drawmoneyimage(x,y)
Color 0,0,0
Oval x-1,y-1,34,34,True
Color 255,255,0
Oval x,y,32,32,True
Color 0,0,0
SetFont fontmoney
Text x+5,y-8,"$"
SetFont font
ormal
End Function

Function drawlifeimage(x,y)
Color 255,0,0
Oval x,y,32,32
Color 5,5,5
SetFont fontmoney
Text x+3,y-8,"H"
SetFont font
ormal
End Function

Function playerdecreasehit()
phits = phits - 1
plinkingdelay = MilliSecs() + 3000
If phits = 0 Then
phits = 3
plives = plives - 1
If plives = 0 Then inigame
End If
End Function

Function inigfx()
gfxall = CreateImage(64,64)
SetBuffer ImageBuffer(gfxall)
Color 255,0,0
Oval 0,0,64,64,True
gfxsmallball = CreateImage(32,32)
SetBuffer ImageBuffer(gfxsmallball)
Color 255,90,0
Oval 0,0,32,32,True
SetBuffer BackBuffer()
End Function

Function freegame()
For a.ai = Each ai
Delete a
Next
For b.bullet = Each bullet
Delete b
Next
For c.rot = Each rot
Delete c
Next
For d.money = Each money
Delete d
Next
End Function


Comments :


Dan(Posted 5 months ago)

 Thanks for the code, here is a Longplay video of the Amiga Game:<iframe width="560" height="345" src="http://www.youtube.com/embed/9eRiOBzVUSE?t=83" frameborder="0" allowfullscreen></iframe>


Blitzplotter(Posted 4 months ago)

 Pakz, awesome piece of coding, thankyou for sharing :)


Pakz(Posted 4 months ago)

 I was thinking of porting the code to Monkey and later to monkey 2. Maybe to blitzmax also if I start using that in the future.I might port it to monkey today if I can sit down and get motivated. Might be nice to have a html5 version of it.Would end up on here : <a href="http://cromdesi.home.xs4all.nl/" target="_blank">http://cromdesi.home.xs4all.nl/</a>


Blitzplotter(Posted 4 months ago)

 I like the SpaceMining AI.