Breakout Clone Problems

Blitz3D Forums/Blitz3D Beginners Area/Breakout Clone Problems

BlueWolf(Posted 2004) [#1]
Hi, I guess this could be defined as a type question.

I have the following code

;Breakout Clone By Bluewolf
;Features Block Counter,Sounds,Sprites

Graphics3D 800,600

;Some Variables
Global lvl1=15 ;the number of blocks in lvl1

Type Block ;Type for block
Field x#,y# ;x,y positions of the blocks
Field ifhit% ;0 if not hit 1 for every hit after
Field red,green,blue ;RGB color values
Field blck ;the block part
End Type

Type Ball ;Type for the bouncy ball
Field x#,y# ;the x,y of the ball
Field ifhit%;if hitting=1 otherwise=0
End Type

Type Paddle ;the player type
Field x#,y# ;the position of the ball
Field Ifhit ;if touching ball=1 otherwise=0
End Type

;Do some functions
CreateBlocks()
;CreatePaddle()
;CreateBall()

While Not KeyDown(1)
;MovePaddle()
;UpdateBall()
;UpdatePaddle()

UpdateWorld
RenderWorld
Flip
Wend
End

Function CreateBlocks()
	tempx=0
	tempy=300

	For i=0 To lvl1
		
		block.block=New Block
		block\x=tempx
		block\y=tempy
		block\ifhit=0
		block\red=Rnd(0,255)
		block\green=Rnd(0,255)
		block\blue=Rnd(0,255)
		block\blck=LoadSprite("sprite.png")
		
		PositionEntity block\blck,block\x,block\y,0
		EntityColor block\blck,block\red,block\green,block\blue
	
	Next
	
End Function 


The problem is it does not display anything. Just a silly noobie question I know but any help will be appreciated.

Thanks,
BlueWolf


MuffinRemnant(Posted 2004) [#2]
Your sprite are all at z=0... so is the default camera.

PositionEntity block\blck,block\x,block\y,0<-----

Try positioning your sprites at say z=20 and you should see 'em (or pull your camera back to say z=-20)


BlueWolf(Posted 2004) [#3]
Hehe it was a joke...I knew that:-)

Thanks MuffinRemnant


MuffinRemnant(Posted 2004) [#4]
Np


BlueWolf(Posted 2004) [#5]
Uh oh...I added the bit about

camera=createcamera()
PositionEntity camera,0,0,-20
and I still get nothing

I tried moving the camera closer and scaling the sprites to no avail either

[edit] I have tried replacing LoadSprite(...) with
	block\blck=LoadImage("sprite.png") 
		
		DrawImage block\blck,block\x,block\y 
	
which still dosen't draw anything. Please could one of you blitz experts help out a poor newb so I can continue on my project.[/edit]


MuffinRemnant(Posted 2004) [#6]
Sorry didn't look too closely first time round...

All your sprites are at the same position...

tempx=0
tempy=300
For i=0 To lvl1
block.block=New Block
block\x=tempx
block\y=tempy

Since they have a Y value of 300 they'll be way out of view from your camera position (off the top of your screen). Set y to 0 and you should see them. Of course they're still all in the same place since you don't change 'tempx' or 'tempy' in the loop.


BlueWolf(Posted 2004) [#7]
What does blitz measure in? I assumed it was 300 pixels but apparently not. Thanks though