i am working on a "game" but i have some problems. Here is my code so far, it isnt complete and i havnt added the text that displays the score. Dont laugh at my bad coding ;)
What i would like is that when the player(camera) touches a ring, the ring dissapears and the score goes up by one. i've made some penguins which you cant touch , if you do then you lose. The problem is that i do not know how to make the collision with the rings and the score thing.
When i tried, the collisions with the rings acted exactly the same as with the penguins. In other words, when i touched a ring, i lost...
Please help me.. i have been trying for too long and need some advice.
thanks Olo
welcome() Function welcome() Graphics 1024, 768 screen=LoadImage("ice_escape1.bmp") DrawImage screen, 0,0 While Not KeyDown(1) If KeyDown(28) Then Return If KeyDown(57) Then Return Wend End Function .start Graphics3D 1280,1024 SetBuffer BackBuffer() SeedRnd MilliSecs() ;collisions type_player=1 type_obstacle=2 type_sphere=3 type_ring=4 ;camera camera=CreateCamera() PositionEntity camera, -360.132,5,692.037 RotateEntity camera, 0,180, 0 EntityType camera, type_player EntityRadius camera, 2 CameraClsColor camera, 0,0,0 ;sound sound=LoadSound("phaser.wav") ;lights light=CreateLight() RotateEntity light,90,0,0 ;heightmap and the terrain maze=LoadTerrain("heightmap6.bmp") ScaleEntity maze, 5,100,5 PositionEntity maze, -500,0,-500 tex1=LoadTexture("ice1.jpg") ScaleTexture tex1, 50,50 EntityTexture maze, tex1 ;penguins Dim spheres(10000) For s=0 To 100 spheres(s)=LoadMesh("penguin.3ds") ScaleEntity spheres(s), 0.05,0.05,0.05 PositionEntity spheres(s), Rand(500,-500), 3,Rand(500,-500) EntityColor spheres(s), 95,95,95 EntityType spheres(s), type_sphere EntityRadius spheres(s), 1 RotateEntity spheres(s), 0,-80,0 Next ;making rings(gems) Dim rings(1000) For r=0 To 100 rings(r)=LoadMesh("ring1.3ds") ScaleEntity rings(r), 0.05,0.05,0.05 PositionEntity rings(r), Rand(500,-500), 3,Rand(500,-500) EntityColor rings(r), 255,255,26 EntityType rings(r), type_ring EntityRadius rings(r), 0.3 Next ;destination uncone... cone=CreateCone() PositionEntity cone, -407, 15, -16.5 EntityColor cone, 255,0,0 ScaleEntity cone, 5,5,5 EntityType maze, type_obstacle EntityRadius maze, 0.1 ;collisions Collisions type_player, type_obstacle,2,1 Collisions type_player,type_sphere,2,1 Collisions type_sphere,type_player,2,1 Collisions type_player, type_ring,2,1 Collisions type_ring, type_player,2,1 ;the timer starttime=MilliSecs() ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;makes game run While Not KeyDown(1) If KeyDown (72)=True Then velocity#=velocity#+0.02 If KeyDown (76)=True Then velocity#=velocity#-0.02 If KeyDown (77)=True Then TurnEntity camera, 0,-1,0 If KeyDown (75)=True Then TurnEntity camera, 0,1,0 MoveEntity camera, 0,0,velocity# ;pausing If KeyDown(25) Then Cls pause=LoadImage ("ice_pause.bmp") DrawImage pause,0,0 Flip WaitKey() EndIf If KeyHit(57) Then PlaySound sound ;making spheres move randomly For i=0 To 100 MoveEntity spheres(i), Rnd(-0.5,0.5), 0, Rnd(-1.2,1.2) Next ;ending game For b=0 To 100 If timeleft < 0 Or crash#=1 Then Cls Graphics 1024,768 End=LoadImage ("ice_end.bmp") DrawImage End,0,0 Flip WaitKey() If KeyDown(1) Or (57) Or (28) Then End If KeyHit (57) Then Goto start EndIf If CountCollisions (spheres(b)) crash=CollisionEntity (spheres(b),1) HideEntity crash crash#=crash#+1 EndIf If CountCollisions (rings(b)) ring=CollisionEntity (rings(b),2) HideEntity ring score#=score#+1 EndIf Next UpdateWorld RenderWorld ;the time CurrentTime = MilliSecs() timeleft= 240000 - ((CurrentTime - starttime)) Text 800,10,"Time Remaining: "+TimeLeft /1000 Flip Wend End
What i would like is that when the player(camera) touches a ring, the ring dissapears and the score goes up by one. i've made some penguins which you cant touch , if you do then you lose. The problem is that i do not know how to make the collision with the rings and the score thing.
When i tried, the collisions with the rings acted exactly the same as with the penguins. In other words, when i touched a ring, i lost...
Please help me.. i have been trying for too long and need some advice.
thanks Olo