'This is for the gun-splash
Type EFFECTS
Field x
Field y
Field size
End Type
DrawToWorld ON 'draw circles onto game world
FrameLimit 40 'limit speed for fast computers
'Load the map and the hero
map=LoadMap("Media\cdm2.til","Media\tileset.bmp")
soldier=LoadObject("Media\soldier.bmp",360)
RotateObject soldier,90 'make the soldier face upwards
SetupCollision soldier,map,1,4,2 'create sliding collision
ObjectRange soldier,30 'set collision range for radius 15
ObjectPickable map,ON 'make map pickable
PlayObject map,0,0,1 'animate map
'Load and set a custom mouse pointer (the crosshair)
crosshair=LoadImage("Media\crosshair.bmp")
ShowMouse crosshair
AddText "Move: WASD, Aim: Mouse, Shoot: Mouse1"
Repeat
'Get the angle to the crosshair and turn to it
aim=GetAngle(200,150,MouseX(),MouseY())
RotateObject soldier,aim
'Update Controls
If KeyDown(cbkeys) Then TranslateObject soldier,0, -3
If KeyDown(cbkeyw) Then TranslateObject soldier,0,3
If KeyDown(cbkeyd) Then TranslateObject soldier,3,0
If KeyDown(cbkeya) Then TranslateObject soldier, -3,0
'Update shooting
If MouseDown(1) And reload=0 Then
ObjectPick soldier
If PickedObject() Then
effect.EFFECTS=New(EFFECTS)
effect\x=PickedX()
effect\y=PickedY()
effect\size=2
EndIf
reload=6
EndIf
If reload Then reload=reload-1
'draw objects and then EFFECTS
DrawGame
GoSub updateEFFECTS
'stick the camera to the soldier and draw screen
UpdateGame
CloneCameraPosition soldier
DrawScreen
Until EscapeKey()
End
':::::::::::::::::::::::::::::::::::::::::::::
'This sub-program will update all existing EFFECTS
updateEFFECTS:
'Iterate all
For effect.EFFECTS=Each EFFECTS
'Draw efefct
Color cbyellow
Circle effect\x-effect\size,effect\y+effect\size,effect\size*2,OFF
'Update effect size
effect\size=effect\size+1
'Remove effect when it gets too large
If effect\size>10 Then Delete effect
Next effect
Return
|
|