;Setup
Graphics3D 800,600,32,2
SeedRnd(MilliSecs())
SetBuffer BackBuffer()
;types
Type Map
Field Mesh
Field Make
End Type
Type Bullet
Field Mesh
Field Age
End Type
;arrays
Dim Map(10,10)
;Variables
Global Quit=False
Global cam
Const Bullet_Life=100
Const Bullet_speed#=0.4
Global Balls=1000
Global Temp
;collions
Const Col_Player=1
Const Col_Scnery=2
Const Col_Blocks=3
Const Col_bullet=4
Collisions Col_Player,Col_Scnery,2,2
Collisions Col_bullet,Col_Scnery,2,2
;main Game
;PLayer loading
Global Player=LoadMesh("ball.3ds")
ScaleMesh Player,0.3,0.3,0.3
EntityType Player,Col_player
EntityRadius Player,0.4
;Main camrea
Cam=CreateCamera(Player);this is the main view camrea
TranslateEntity Cam,0,1,-3
PointEntity Cam,PLayer
;Light
light=CreateLight();Creates a light
;INfinte plane
plane=CreatePlane();Makes a simple infinte plane
grass_tex=LoadTexture( "media/metal.png" );loads planes texture
EntityTexture plane,grass_tex;set planes texture
PositionEntity plane,0,-1,0;positions the plane
EntityType Plane,Col_scnery
;EntityAlpha plane,0.9
;mirror=CreateMirror()
;Map camrea
cam2=CreateCamera(cam);Creates the map camrea
TranslateEntity cam2,0,5,0
PointEntity cam2,plane
CameraViewport cam2,0,500,100,100;positions the map
;create the random map
Generate_map()
create_map()
;Physics()
Repeat;Main loop
Movement
Shoot
Update_Bullets
Block_Checker()
UpdateWorld
RenderWorld
GUI
Flip
Finish
Until Quit=True
;end of main loop
;Functions
Function Finish();Detects if the game has finished
If KeyHit(1)
Quit=True
EndIf
End Function
Function Generate_map();Generates the 2d map cordanites
For x=0 To 10
For y=0 To 10
Map(x,y)=Rnd(1,10)
DebugLog map(x,y)
Next
Next
End Function
Function Create_map();Generates the 3d visible map
For x=0 To 10
For y=0 To 10
If map(x,y)=2
a.Map = New map
a\Mesh =CreateCube ()
EntityType a\mesh,Col_Scnery
PositionEntity a\mesh,x,0,y
ScaleEntity a\mesh,0.5,1,0.5
a\Make = Map(x,y)
EndIf
Next
Next
End Function
Function Movement();Controls the players movement
If KeyDown( 205 )=True Then TurnEntity Player,0,-1,0
If KeyDown( 203 )=True Then TurnEntity Player,0,1,0
If KeyDown( 208 )=True Then MoveEntity Player,0,0,-0.05
If KeyDown( 200 )=True Then MoveEntity Player,0,0,0.05
End Function
Function Shoot()
If KeyHit(57)
If Balls > 0
b.Bullet = New bullet
b\Mesh = CreateSphere()
EntityType b\mesh,Col_bullet
ScaleMesh b\mesh,0.1,0.1,0.1
PositionEntity b\mesh,EntityX(Player),0,EntityZ(player)
RotateEntity b\mesh,0,EntityYaw(Player),0
b\Age=1
Balls=Balls-1
Else
EndIf
EndIf
End Function
Function Update_Bullets()
For all.Bullet = Each Bullet
MoveEntity all\mesh,0,0,Bullet_speed#
all\Age =all\Age + 1
If all\Age >= Bullet_Life
FreeEntity all\Mesh
Delete all
EndIf
Next
End Function
Function GUI()
Color 225,225,225
Text 0,0,Balls
End Function
Function Block_Checker()
temp=0
For a.bullet=Each bullet
temp=EntityCollided(a\mesh,Col_Scnery)
If temp>0 Then Block_destroy(Temp)
If temp>0 Then FreeEntity a\mesh:Delete a:temp=0
Next
End Function
Function Block_destroy(temp)
For b.map=Each map
If b\mesh=temp Then FreeEntity b\mesh:Delete b
Next
End Function
try this out got it working is destroying the blocks
Graphics3D 800,600,32,2
SeedRnd(MilliSecs())
SetBuffer BackBuffer()
;types
Type Map
Field Mesh
Field Make
End Type
Type Bullet
Field Mesh
Field Age
End Type
;arrays
Dim Map(10,10)
;Variables
Global Quit=False
Global cam
Const Bullet_Life=100
Const Bullet_speed#=0.4
Global Balls=1000
Global Temp
;collions
Const Col_Player=1
Const Col_Scnery=2
Const Col_Blocks=3
Const Col_bullet=4
Collisions Col_Player,Col_Scnery,2,2
Collisions Col_bullet,Col_Scnery,2,2
;main Game
;PLayer loading
Global Player=LoadMesh("ball.3ds")
ScaleMesh Player,0.3,0.3,0.3
EntityType Player,Col_player
EntityRadius Player,0.4
;Main camrea
Cam=CreateCamera(Player);this is the main view camrea
TranslateEntity Cam,0,1,-3
PointEntity Cam,PLayer
;Light
light=CreateLight();Creates a light
;INfinte plane
plane=CreatePlane();Makes a simple infinte plane
grass_tex=LoadTexture( "media/metal.png" );loads planes texture
EntityTexture plane,grass_tex;set planes texture
PositionEntity plane,0,-1,0;positions the plane
EntityType Plane,Col_scnery
;EntityAlpha plane,0.9
;mirror=CreateMirror()
;Map camrea
cam2=CreateCamera(cam);Creates the map camrea
TranslateEntity cam2,0,5,0
PointEntity cam2,plane
CameraViewport cam2,0,500,100,100;positions the map
;create the random map
Generate_map()
create_map()
;Physics()
Repeat;Main loop
Movement
Shoot
Update_Bullets
Block_Checker()
UpdateWorld
RenderWorld
GUI
Flip
Finish
Until Quit=True
;end of main loop
;Functions
Function Finish();Detects if the game has finished
If KeyHit(1)
Quit=True
EndIf
End Function
Function Generate_map();Generates the 2d map cordanites
For x=0 To 10
For y=0 To 10
Map(x,y)=Rnd(1,10)
DebugLog map(x,y)
Next
Next
End Function
Function Create_map();Generates the 3d visible map
For x=0 To 10
For y=0 To 10
If map(x,y)=2
a.Map = New map
a\Mesh =CreateCube ()
EntityType a\mesh,Col_Scnery
PositionEntity a\mesh,x,0,y
ScaleEntity a\mesh,0.5,1,0.5
a\Make = Map(x,y)
EndIf
Next
Next
End Function
Function Movement();Controls the players movement
If KeyDown( 205 )=True Then TurnEntity Player,0,-1,0
If KeyDown( 203 )=True Then TurnEntity Player,0,1,0
If KeyDown( 208 )=True Then MoveEntity Player,0,0,-0.05
If KeyDown( 200 )=True Then MoveEntity Player,0,0,0.05
End Function
Function Shoot()
If KeyHit(57)
If Balls > 0
b.Bullet = New bullet
b\Mesh = CreateSphere()
EntityType b\mesh,Col_bullet
ScaleMesh b\mesh,0.1,0.1,0.1
PositionEntity b\mesh,EntityX(Player),0,EntityZ(player)
RotateEntity b\mesh,0,EntityYaw(Player),0
b\Age=1
Balls=Balls-1
Else
EndIf
EndIf
End Function
Function Update_Bullets()
For all.Bullet = Each Bullet
MoveEntity all\mesh,0,0,Bullet_speed#
all\Age =all\Age + 1
If all\Age >= Bullet_Life
FreeEntity all\Mesh
Delete all
EndIf
Next
End Function
Function GUI()
Color 225,225,225
Text 0,0,Balls
End Function
Function Block_Checker()
temp=0
For a.bullet=Each bullet
temp=EntityCollided(a\mesh,Col_Scnery)
If temp>0 Then Block_destroy(Temp)
If temp>0 Then FreeEntity a\mesh:Delete a:temp=0
Next
End Function
Function Block_destroy(temp)
For b.map=Each map
If b\mesh=temp Then FreeEntity b\mesh:Delete b
Next
End Function
try this out got it working is destroying the blocks