beginers comunity project-arkanoid 3d

Blitz3D Forums/Blitz3D Beginners Area/beginers comunity project-arkanoid 3d

i think that the beginers(like me)need this project to advance faster. just by posting my origanal arkanoid clone, i recieved comments that have helped me to make my programing so much better, here is the last version of arkanoid that i'm gunna make. use it if you want although its probably flawed.


;================program setup======================
AppTitle "block blaster 3D"
Graphics3D 1000,700,16,2; set the graphics window
SetBuffer BackBuffer();drawing buffer
; camera and light creation===========
camera=CreateCamera();the players camera
CameraViewport camera,0,0,1000,700
PositionEntity camera,0,40,-40
light=CreateLight()
;ball creation========================
Global ball2=CreateSphere();power up ball
PositionEntity ball2,0,0,70
EntityColor ball2,0,200,0;color the ball green
ScaleEntity ball2,2,2,2;make the ball biger
;ball creation two======================
Global ball=CreateSphere();main ball
PositionEntity ball,0,40,10
EntityColor ball,200,200,0;color the ball yellow
ScaleEntity ball,2,2,2;make the ball biger
;bat creation=====================
;topleft bat
Global batlt=CreateCube();players bat top left corner
PositionEntity batlt,0,40,-5
ScaleEntity batlt,6,6,.5 
EntityColor batlt,200,0,0
EntityAlpha batlt,.5 
;toprightbat
Global batrt=CreateCube();players bat top right corner
PositionEntity batrt,12,40,-5
ScaleEntity batrt,6,6,.5 
EntityColor batrt,200,0,0
EntityAlpha batrt,.5 
;bottum right bat
Global batrb=CreateCube();players bat bottum right corner
PositionEntity batrb,12,28,-5
ScaleEntity batrb,6,6,.5 
EntityColor batrb,200,0,0
EntityAlpha batrb,.5 
;bottum left bat
Global batlb=CreateCube();players bat bottum left corner
PositionEntity batlb,0,28,-5
ScaleEntity batlb,6,6,.5 
EntityColor batlb,200,0,0
EntityAlpha batlb,.5 
;============entity parent all bat pieces and camera together========
EntityParent batrt,batlt
EntityParent batrb,batlt
EntityParent batlb,batlt
EntityParent camera,batlt
;walls creation===================
;bottumwall details
Global bottumwall=CreateCube()
EntityColor bottumwall,100,100,100 
PositionEntity bottumwall,0,1,70
ScaleEntity bottumwall,70,1,150
;leftwall details
Global leftwall=CreateCube()
EntityColor leftwall,100,0,0 
PositionEntity leftwall,-60,40,70
ScaleEntity leftwall,1,70,150
;rightwall details
Global rightwall=CreateCube()
EntityColor rightwall,100,0,0 
PositionEntity rightwall,60,40,70
ScaleEntity rightwall,1,70,150
;topwall details
Global topwall=CreateCube()
EntityColor topwall,100,100,100 
PositionEntity topwall,0,100,70
ScaleEntity topwall,70,1,150
;backwall details
Global backwall=CreateCube()
EntityColor backwall,50,50,50 
PositionEntity backwall,0,40,220
ScaleEntity backwall,70,70,1
;===========power pill creation=============
Global powerpill=CreateCube();power up pill that drifts across the screen
ScaleEntity powerpill,3,3,3
EntityColor powerpill,255,0,255
PositionEntity powerpill,0,-10,50;place it below world so that it cant be seen untill its time
;==========pill creation===========
SeedRnd MilliSecs()
Type pill
Field pillx
Field pilly
Field red;pill random color red
Field grn;pill random color green
Field blu;pill random color blu
Field hp;pill hp 1 for on 0 for off
Field pillmesh
End Type
For tmpx=-45 To 39 Step 6 
For tmpy=10 To 88 Step 6
pills.pill=New pill
pills\pillx=tmpx;make each pills x coordinates
pills\pilly=tmpy;make each pills y coordinates
pills\red=Rand(100,200);random red of pill
pills\grn=Rand(100,200);random green of pill
pills\blu=Rand(100,200);random blue of pill
pills\hp=1;set pill hp
pills\pillmesh=CreateCube();the actual pills mesh
Next 
Next
;pill positioning scaling And coloring====
pills.pill=First pill 
PositionEntity pills\pillmesh,pills\pillx,pills\pilly,100;position of the first pill
EntityColor pills\pillmesh,pills\red,pills\grn,pills\blu;random color of the first pill that was set earlier
ScaleEntity pills\pillmesh,3,3,3;make the first pill bigger
EntityType pills\pillmesh,9;entity type the first pill as 9
For tmp=1 To 209
pills=After pills  
PositionEntity pills\pillmesh,pills\pillx,pills\pilly,100;position of the pills
EntityColor pills\pillmesh,pills\red,pills\grn,pills\blu;the random color of pills that was set earlier
ScaleEntity pills\pillmesh,3,3,3;make the pills bigger
EntityType pills\pillmesh,tmp+9;entity type the pills as 10 to 219
Next
;globals==================================
Global ballmove=0;wether the ball is moving 1 for yes 0 for no
Global ballzspeed=-2;z speed of ball1
Global ballxspeed#=0;x speed of ball1
Global ballyspeed#=0;y speed of ball1
Global powerchance=0;the  random number of wether you get a power up or not(gets set later)
Global oldpower=0;wether you have a power up 1 for yes 0 for no
Global newball=0;wether ball no 2 is in play
Global ballzspeed2=-2;ball2 z speed
Global ballxspeed2#=0;ball2 x speed
Global ballyspeed2#=0;ball2 y speed
Global lives=5;the amount of lives a player has
Global pops=0;the amount of pills poped
;=========================================
;entity typeing
EntityType ball,1;ball is the first type
EntityType batlt,2;bat left top is the second type
EntityType batrt,3;bat right top is the third type
EntityType batlb,4;bat left bottum is the forth type
EntityType batrb,5;bat right bottum is the fith type
EntityType backwall,6;backwall is a sixth Type
EntityType rightwall,7;rightwall is a seventh Type
EntityType leftwall,7;leftwall is a seventh Type
EntityType bottumwall,8;bottumwall is ta eighth Type
EntityType topwall,8;topwall is a eighth Type
EntityType powerpill,220;powerpill is the 220th type
EntityType ball2,221;second ball is the 221st type
;======================================central program===========================================
While KeyDown(1)=False;loops untill escape is pressed
If ballmove=0 Then PositionEntity ball,EntityX(batlt)+5,EntityY(batlt)-5,EntityZ(batlt)+10;keeps the ball in front of the bat when its not moving
;function calling==========
If ballmove=1 ballmovement();goto ball movement
If newball=1 ballmovement2();goto second balls movement
If powerchance>4 And oldpower=0 And newball=0 Then powerpill();goto the powerpill setings
;controls==================
If EntityX(batlt)>-52 And KeyDown(203) Then MoveEntity batlt,-2,0,0
If EntityX(batlt)<40 And KeyDown(205) Then MoveEntity batlt,2,0,0
If EntityY(batlt)<92 And KeyDown(200) Then MoveEntity batlt,0,2,0
If EntityY(batlt)>20 And KeyDown(208) Then MoveEntity batlt,0,-2,0
If KeyDown(57) Then ballmove=1;starts the ball moving
Delay 1
;powerpill control==========
If oldpower>0 MoveEntity powerpill,0,0,-1;moves the powerup closer towards the screen
If EntityZ(powerpill)<-50 Then oldpower=0:powerchance=0;removes powerup from play if you miss it
For tmp=2 To 5
Collisions 220,tmp,2,3;colides the pill with the bat
If EntityCollided(powerpill,tmp) Then newball=1:PositionEntity ball2,EntityX(batlt)+5,EntityY(batlt)-5,EntityZ(batlt)+20:ballzspeed2=2:ballxspeed2#=0:ballyspeed2#=0:PositionEntity powerpill,0,-10,50
Next
If lives=0 Then End;if  your lives run out goto the gameover part
;===========================
UpdateWorld
RenderWorld
Color 255,255,255:Text 50,650,"balls left "+lives+"    pills popped "+pops;the onscreen Text that tells how many lives you have left and the score
Flip
Wend;jumps back to begining of loop if escape has not been pressed
End
;================================================================================================
;powerpill
Function powerpill()
PositionEntity powerpill,EntityX(ball),EntityY(ball),EntityZ(ball);places powerup at balls location
oldpower=1;lets the rest of the program know that the powerups in play
End Function
;===============ball movement and colision test==================
Function ballmovement()
;ballmovement
MoveEntity ball,ballxspeed#,ballyspeed#,ballzspeed; moves the ball at the designated speeds
;ball collisions with bat
Collisions 1,2,2,3;collisions with the bat
Collisions 1,3,2,3
Collisions 1,4,2,3
Collisions 1,5,2,3
If EntityCollided(ball,2) Then ballzspeed=ballzspeed-ballzspeed*2:ballxspeed#=ballxspeed#-.1:ballyspeed#=ballyspeed#+.1:MoveEntity ball,0,0,ballzspeed
If EntityCollided(ball,3) Then ballzspeed=ballzspeed-ballzspeed*2:ballxspeed#=ballxspeed#+.1:ballyspeed#=ballyspeed#+.1:MoveEntity ball,0,0,ballzspeed
If EntityCollided(ball,4) Then ballzspeed=ballzspeed-ballzspeed*2:ballxspeed#=ballxspeed#-.1:ballyspeed#=ballyspeed#-.1:MoveEntity ball,0,0,ballzspeed
If EntityCollided(ball,5) Then ballzspeed=ballzspeed-ballzspeed*2:ballxspeed#=ballxspeed#+.1:ballyspeed#=ballyspeed#-.1:MoveEntity ball,0,0,ballzspeed
;ball collision with back wall
Collisions 1,6,2,3
If EntityCollided(ball,6) Then ballzspeed=ballzspeed-ballzspeed*2:MoveEntity ball,0,0,ballzspeed
;ball collisions with top and bottum wall
Collisions 1,8,2,3
If EntityCollided(ball,8) Then ballyspeed=ballyspeed-ballyspeed*2:MoveEntity ball,0,ballyspeed,0
;ball collisions with left and right wall
Collisions 1,7,2,3
If EntityCollided(ball,7) Then ballxspeed=ballxspeed-ballxspeed*2:MoveEntity ball,ballxspeed,0,0
;ball collision with pills
SeedRnd=MilliSecs
pills.pill=First pill
Collisions 1,9,2,3
If EntityCollided(ball,9) Then ballzspeed=ballzspeed-ballzspeed*2:MoveEntity ball,0,0,ballzspeed:HideEntity pills\pillmesh:powerchance=Rand(1,5):pops=pops+1
For tmp=10 To 217
pills=After pills 
Collisions 1,tmp,2,3
If EntityCollided(ball,tmp) Then ballzspeed=ballzspeed-ballzspeed*2:MoveEntity ball,0,0,ballzspeed:HideEntity pills\pillmesh:powerchance=Rand(1,5):pops=pops+1
Next
;ball lost
If EntityZ (ball)<-20 Then PositionEntity ball,0,0,0:ballmove=0:ballxspeed=0:ballyspeed=0:lives=lives-1
End Function
;===============ball two movement and colision test==================
Function ballmovement2()
;ballmovement
MoveEntity ball2,ballxspeed2#,ballyspeed2#,ballzspeed2
;ball collisions with bat
Collisions 221,2,2,3
Collisions 221,3,2,3
Collisions 221,4,2,3
Collisions 221,5,2,3
If EntityCollided(ball2,2) Then ballzspeed2=ballzspeed2-ballzspeed2*2:ballxspeed2#=ballxspeed2#-.1:ballyspeed2#=ballyspeed2#+.1:MoveEntity ball2,0,0,ballzspeed2
If EntityCollided(ball2,3) Then ballzspeed2=ballzspeed2-ballzspeed2*2:ballxspeed2#=ballxspeed2#+.1:ballyspeed2#=ballyspeed2#+.1:MoveEntity ball2,0,0,ballzspeed2
If EntityCollided(ball2,4) Then ballzspeed2=ballzspeed2-ballzspeed2*2:ballxspeed2#=ballxspeed2#-.1:ballyspeed2#=ballyspeed2#-.1:MoveEntity ball2,0,0,ballzspeed2
If EntityCollided(ball2,5) Then ballzspeed2=ballzspeed2-ballzspeed2*2:ballxspeed2#=ballxspeed2#+.1:ballyspeed2#=ballyspeed2#-.1:MoveEntity ball2,0,0,ballzspeed2
;ball collision with back wall
Collisions 221,6,2,3
If EntityCollided(ball2,6) Then ballzspeed2=ballzspeed2-ballzspeed2*2:MoveEntity ball2,0,0,ballzspeed2
;ball collisions with top and bottum wall
Collisions 221,8,2,3
If EntityCollided(ball2,8) Then ballyspeed2#=ballyspeed2#-ballyspeed2#*2:MoveEntity ball2,0,ballyspeed2#,0
;ball collisions with left and right wall
Collisions 221,7,2,3
If EntityCollided(ball2,7) Then ballxspeed2#=ballxspeed2#-ballxspeed2#*2:MoveEntity ball2,ballxspeed2#,0,0
;ball collision with pills
pills.pill=First pill
Collisions 221,9,2,3
If EntityCollided(ball2,9) Then ballzspeed2=ballzspeed2-ballzspeed2*2:MoveEntity ball2,0,0,ballzspeed2:HideEntity pills\pillmesh:pops=pops+1
For tmp=10 To 217
pills=After pills 
Collisions 221,tmp,2,3
If EntityCollided(ball2,tmp) Then ballzspeed2=ballzspeed2-ballzspeed2*2:MoveEntity ball2,0,0,ballzspeed2:HideEntity pills\pillmesh:pops=pops+1
Next
;ball lost
If EntityZ (ball2)<-50 Then newball=0:ballxspeed2#=0:ballyspeed2#=0:ballzspeed2=2:oldpower=0:powerchance=0:PositionEntity ball2,0,0,-20
End Function





Nice work. Good game.

Great concept!

A 3D Arkanoid!

I think it could make kind of a cool racketball game. Just change the box into a paddle speed enery thing up and make it so you have to swing the paddle at just the right moment to hit the ball.