Hi this Vee
I figured, I would show you a game I made, its a racing game.
The object of the game is to dodge the boxs.
Hide Mouse
Remstart *** Vee's Dodge Racer! 2008
Controls
Use the mouse to dodge left or right
The object of the game is not to hit a box, to win the game.
remend
Set Display Mode 1024,768,Screen depth()
Sync on : Sync rate 60
randomize timer()
Game:
Type PlayerType
ObjNum As Integer
PosX As Integer
PosY As Integer
PosZ As Integer
OldPosX As Integer
OldPosY As Integer
OldPosZ As Integer
Speed As Float
TurnSpeed As Float
TurnSpeed2 As Float
MPH As Float
EndType
Type MakeRoadType
ObjNum As Integer
PosX As Integer
PosY As Integer
PosZ As integer
EndType
Type MakeLeftWallType
ObjNum As Integer
PosX As Integer
PosY As Integer
PosZ As integer
EndType
Type MakeRightWallType
ObjNum As Integer
PosX As Integer
PosY As Integer
PosZ As integer
EndType
Type MakeBoxType
ObjNum As Integer
PosX As Integer
PosY As Integer
PosZ As Integer
OldPosX As Integer
OldPosY As Integer
OldPosZ As Integer
EndType
Global Car1 As PlayerType
Global Road As MakeRoadType
Global WallL As MakeLeftWallType
Global WallR As MakeRightWallType
Global Message As Integer
Global lives As Integer = 6
Global GameState As Integer
Global FlashCount As Integer
Global CarDamage As Integer
Global Score As Integer
Global ScoreTimer As Integer = Timer()
Global ScoreInterval = 10000
Global ScoreEnabled As Integer
Global DamageCount As Integer
Dim Boxs(115) As MakeBoxType
MakeGameOver()
MakeRoadTexture()
MakeRoad(2)
MakeLeftWall(3)
MakeRightWall(4)
MakePlayer(10000)
MakeFlashHit()
MakeFinishLine()
For CountBoxes = 0 to 115
MakeBoxs(CountBoxes)
Next CountBoxes
StartCamera()
Do
FollowCamera()
Car1Controls()
WallCollision()
Damage()
FlashAction()
GameOver()
WinGame()
For CountBoxes = 0 to 115
RespawnBoxes(CountBoxes)
CarCollision(CountBoxes)
Next CountBoxes
Set Text Size 28
Text 320,0,"Vee's Dodge Racer! 2008"
Text 760,0,"Lives: " + str$(lives)
Text 20,0,"Score: " + str$(Score)
Text 760,40,"Damage: " + str$(CarDamage)
sync
loop
Function StartCamera()
Position Camera 0,900,0
Point Camera 0,0,0
Set Camera Range 1,100000000
EndFunction
Function FollowCamera()
Position Camera Object Position X(Car1.ObjNum),10,Object Position Z(Car1.ObjNum)-27
Point Camera Object Position X(Car1.ObjNum),0,Object Position Z(Car1.ObjNum)
EndFunction
Function MakeRoadTexture()
Create bitmap 1,128,128
box 0,0,2,64
Blur Bitmap 1,2
Get Image 1,0,0,128,128
Set Current Bitmap 0
EndFunction
Function MakePlayer(i)
Car1.ObjNum = i
Make Object Cube i,1
Car1.PosX = 0
Car1.PosY = 2
Car1.PosZ = 0
Scale Object Car1.ObjNum,200,100,800
Position Object Car1.ObjNum,Car1.PosX,Car1.PosY,Car1.PosZ
` SET OBJECT COLLISION TO BOXES Car1.ObjNum
Make Object Cube 200,1
Scale Object 200,100,100,175
Make Mesh From Object 1,200
Delete Object 200
Add Limb Car1.ObjNum,1,1
Offset Limb Car1.ObjNum,1,0,0,1.5
Hide limb Car1.objNum,1
Delete Mesh 1
EndFunction
Function MakeRoad(i)
Road.ObjNum = i
Make Object Plain Road.ObjNum,100,600000
Rotate Object Road.ObjNum,-90,0,0
Color Object Road.ObjNum,rgb(0,0,0)
Texture object Road.ObjNum,1
Scale object texture Road.ObjNum,4.0,1024.0
Disable Object Zwrite Road.ObjNum
EndFunction
Function MakeLeftWall(i)
WallL.ObjNum = i
Make Object Cube WallL.ObjNum,2
Scale Object WallL.ObjNum,100,400,30000000
Position Object WallL.ObjNum,WallL.PosX-50,0,0
Disable Object Zwrite WallL.ObjNum
EndFunction
Function MakeRightWall(i)
WallR.objNum = i
Make Object Cube WallR.ObjNum,2
Scale Object WallR.ObjNum,100,400,30000000
Position Object WallR.ObjNum,WallR.PosX+50,0,0
Disable Object Zwrite WallR.ObjNum
EndFunction
Function MakeBoxs(CountBoxes As Integer)
Boxs(CountBoxes).ObjNum = CountBoxes+1000
Make object Cube Boxs(CountBoxes).objNum,10
Position Object Boxs(CountBoxes).ObjNum,Boxs(CountBoxes).PosX-45+rnd(90),Boxs(CountBoxes).PosY+2,Object Position Z(Car1.ObjNum)*1000000+rnd(15000)
Color object Boxs(CountBoxes).ObjNum,RGB(120,120,0)
`SET OBJECT COLLISION TO BOXES Boxs(CountBoxes).ObjNum
EndFunction
Function Car1Controls()
If Car1.Speed > 3.0 then Car1.Speed = 3.0
Car1.Speed = Car1.Speed + 0.08
If Car1.MPH > 300.0 then Car1.MPH = 300.0
Car1.MPH = Car1.MPH + 0.08
Move Object Car1.ObjNum,Car1.Speed
If Car1.TurnSpeed > 1.5 then Car1.TurnSpeed = 1.5
Car1.TurnSpeed = Car1.TurnSpeed + 1.5
Move Object Right Car1.ObjNum,Car1.TurnSpeed*MouseMoveX()*0.1
If Car1.TurnSpeed < -1.5 then Car1.TurnSpeed = -1.5
Car1.TurnSpeed = Car1.TurnSpeed - 1.5
Move Object Left Car1.ObjNum,-Car1.TurnSpeed*MouseMoveX()*-0.1
Text 100,650,"MPH: " + str$(int(Car1.MPH))
EndFunction
Function WallCollision()
If Object Position X(Car1.ObjNum) >= Object Position X(WallR.ObjNum)
Car1.PosX = 49.4
Position Object Car1.ObjNum,Car1.PosX,Car1.PosY,Car1.PosZ
Car1.Speed = 0.0
Car1.MPH = 0.1
Move Object Car1.ObjNum,Car1.Speed
DamageCount = 20
Endif
If Object Position X(Car1.ObjNum) <= Object Position x(WallL.ObjNum)
Car1.PosX = -49.4
Position object Car1.objNum,Car1.PosX,Car1.PosY,Car1.PosZ
Car1.Speed = 0.0
Car1.MPH = 0.1
Move Object Car1.ObjNum,Car1.Speed
DamageCount = 20
Endif
If Object Position Z(Car1.ObjNum) = Object position Z(16000)
Car1.PosZ = 100000.0
Position object Car1.objNum,Car1.PosX,Car1.PosY,Car1.PosZ
Car1.Speed = 0.0
Car1.MPH = 0.1
Move Object Car1.ObjNum,Car1.Speed
Endif
EndFunction
Function RespawnBoxes(CountBoxes As integer)
If Object Position Z(Car1.ObjNum) > Object Position Z(Boxs(CountBoxes).ObjNum) `or Object Position Z(Boxs(CountBoxes).ObjNum) < Object Position Z(Car1.ObjNum)
Position Object Boxs(CountBoxes).ObjNum,Boxs(CountBoxes).PosX-45+rnd(90),Boxs(CountBoxes).PosY+2,Object Position Z(Car1.ObjNum)*4+rnd(2)
Endif
EndFunction
Function CarCollision(CountBoxes As Integer)
Car1.OldPosX = Car1.PosX
Car1.OldPosY = Car1.PosY
Car1.OldPosZ = Car1.PosZ
Boxs(CountBoxes).OldPosX = Boxs(CountBoxes).PosX
Boxs(CountBoxes).OldPosY = Boxs(CountBoxes).PosY
Boxs(CountBoxes).OldPosZ = Boxs(CountBoxes).PosZ
If ScoreEnabled = 1
If Car1.MPH > 50.0
If timer() > ScoreTimer + ScoreInterval
Score = Score + 1
If Score = 10 then lives = lives + 1
ScoreTimer = Timer()
Endif
Endif
Endif
If Message = 1
Position Object Boxs(CountBoxes).ObjNum,Boxs(CountBoxes).PosX-45+rnd(90),Boxs(CountBoxes).PosY+2,Object Position Z(Car1.ObjNum)*1000000+rnd(17000)
`Text 20,80,"Collision!"
Else
Message = 0
`Text 20,100,"No Collision!"
Endif
If Intersect object(Boxs(CountBoxes).ObjNum, Limb Position X(Car1.ObjNum,1), Limb Position Y(Car1.ObjNum,1), Limb Position Z(Car1.ObjNum,1), Object Position X(Car1.ObjNum),Object Position Y(Car1.ObjNum),Object Position Z(Car1.objNum))> 0
Message = 1
FlashCount = 10
lives = lives - 1
CarDamage = 0
Car1.PosX = 0
Car1.PosY = 2
Car1.PosZ = 0
Car1.Speed = 0.0
Car1.MPH = 0.1
Color Object Car1.ObjNum,RGB(255,255,255)
Position Object Car1.ObjNum,PosX,Car1.PosY,Car1.PosZ
Position Object Boxs(CountBoxes).ObjNum,Boxs(CountBoxes).PosX,Boxs(CountBoxes).PosY,Boxs(CountBoxes).PosZ
If Score > 0 then Score = Score - 1
Else
Message = 0
ScoreEnabled = 1
Endif
If lives = 0 then GameState = 1
EndFunction
Function MakeFlashHit()
Make object plain 15000,1024,768
Color object 15000,RGB(255,0,0)
Hide Object 15000
EndFunction
Function FlashAction()
If FlashCount > 0
FlashCount = FlashCount - 1
Show Object 15000
Position Object 15000,Camera Position x(),Camera Position Y(),Camera Position z()+5
Else
Hide Object 15000
Endif
EndFunction
Function MakeGameOver()
Make object plain 20000,1024,768
Color object 20000,RGB(255,0,0)
Hide object 20000
EndFunction
Function GameOver()
If GameState = 1
Show object 20000
Car1.MPH = 0.0
Car1.PosX = 0
Car1.PosY = 2
Car1.PosZ = 0
Car1.Speed = 0.0
Score = 0
Position object 20000,Camera Position x(),Camera Position Y(),Camera Position z()+5
Color object 20000,RGB(255,0,0)
Text 120,200,"Game Over!!! Press 'Y' To Play Again. Or 'Q' to quit"
If keyState(21)=1
for i = 1 to 20001
delete object i
Next i
Goto Game
Else
If KeyState(16)=1 then end
Endif
Endif
If GameState = 2
Show object 20000
Car1.MPH = 0.0
Car1.PosX = 0
Car1.PosY = 2
Car1.PosZ = 0
Car1.Speed = 0.0
Score = 0
Position object 20000,Camera Position x(),Camera Position Y(),Camera Position z()+5
Color object 20000,RGB(0,255,0)
Text 120,200,"You Win,! Wow I can't believe it, You Are The Man!"
Text 120,240,"Press 'Y' To Play Again. Or 'Q' to quit"
If keyState(21)=1
for i = 1 to 20001
delete object i
Next i
Goto Game
Else
If KeyState(16)=1 then end
Endif
Endif
EndFunction
Function Damage()
If DamageCount > 0
DamageCount = DamageCount - 1
FlashCount = 2
If DamageCount = 1 then CarDamage = CarDamage + 1
If CarDamage = 1 then Color object Car1.ObjNum,RGB(255,150,150)
If CarDamage = 2 then Color object Car1.ObjNum,RGB(255,60,60)
If CarDamage = 3 then Color object Car1.ObjNum,RGB(255,0,0)
If CarDamage = 4
lives = lives - 1
CarDamage = 0
Endif
If CarDamage = 0 then Color Object Car1.ObjNum,RGB(255,255,255)
If lives = 0 then GameState = 1
Endif
EndFunction
Function WinGame()
If Object Position Z(Car1.ObjNum) > 300000.0
Car1.Speed = 0.0
GameState = 2
Endif
EndFunction
Function MakeFinishLine()
Make object cube 16000,2
Scale object 16000,6000,1800,100
Position object 16000,0,0,300000.0
Color object 16000,rgb(0,255,0)
EndFunction
Vee