Style Jezzball game
Blitz3D Forums/Blitz3D Beginners Area/Style Jezzball game
| ||
Hi! I'm trying to make a Jezzball clone but i'm stuck with a problem, i really don't know how to create the rectangles... My code is below: AppTitle "Jezzball Clone v 0.2" Graphics 800,600,16,2 SetBuffer BackBuffer() ; Constantes para o teclado Const botaoEsquerdo = 1 Const botaoDireito = 2 ; Variáveis de ajuda Global podeCriarLinhas = True ; só pode criar uma linha por vez ! Const velocidadeLinha = 1 ; definindo um tipo para o cursor Type CURSOR Field x ; posição no eixo x do cursor Field y ; posição no eixo y do cursor Field altura ; altura do cursor Field largura ; largura do cursor End Type ; definindo paredes Type PAREDE Field x ; x da parede Field y ; y da parede Field altura ; altura da parede Field largura ; largura da parede End Type ; definindo tipo pra linhas Type LINHA_HORIZONTAL Field x ; posição x da linha Field xFim ; fim do x da linha Field y ; posição y da linha Field yFim ; fim do y da linha End Type Type LINHA_VERTICAL Field x ; posição x da linha Field xFim ; fim do x da linha Field y ; posição y da linha Field yFim ; fim do y da linha End Type ; Criação do cursor cursor.CURSOR = New CURSOR cursor\x = 320 cursor\y = 240 cursor\altura = 4 cursor\largura = 4 ; Criação das paredes paredePrincipal.PAREDE = New PAREDE paredePrincipal\x = 220 paredePrincipal\y = 20 paredePrincipal\altura = 560 paredePrincipal\largura = 560 ; LOOP! While Not KeyHit(1) Cls ; Movimentação do cursor cursor\x = MouseX() cursor\y = MouseY() ; Criando linhas If (MouseHit(botaoEsquerdo) And podeCriarLinhas = True) And ((MouseX() > paredePrincipal\x) And (MouseX() < paredePrincipal\y + paredePrincipal\altura)) And ((MouseY() > paredePrincipal\y) And (MouseY() < paredePrincipal\x + paredePrincipal\largura)) linhaH.LINHA_HORIZONTAL = New LINHA_HORIZONTAL linhaH\x = MouseX() linhaH\xFim = MouseX() linhaH\y = MouseY() linhaH\yFim = MouseY() EndIf If (MouseHit(botaoDireito) And podeCriarLinhas = True) And ((MouseX() > paredePrincipal\x) And (MouseX() < paredePrincipal\y + paredePrincipal\altura)) And ((MouseY() > paredePrincipal\y) And (MouseY() < paredePrincipal\x + paredePrincipal\largura)) linhaV.LINHA_VERTICAL = New LINHA_VERTICAL linhaV\x = MouseX() linhaV\xFim = MouseX() linhaV\y = MouseY() linhaV\yFim = MouseY() EndIf ; Var para criação de linhas podeCriarLinhas = True ; Desenhando linha horizontal For linhaH = Each LINHA_HORIZONTAL If (linhaH\x > paredePrincipal\x) linhaH\x = linhaH\x - velocidadeLinha podeCriarLinhas = False ; ainda ta desenhando alguma linha EndIf If (linhaH\xFim < paredePrincipal\y + paredePrincipal\altura) linhaH\xFim = linhaH\xFim + velocidadeLinha podeCriarLinhas = False ; ainda ta desenhando alguma linha EndIf Line linhaH\x,linhaH\y,linhaH\xFim,linhaH\yFim Next ; Desenhando linha vertical For linhaV = Each LINHA_VERTICAL If (linhaV\y > paredePrincipal\y) linhaV\y = linhaV\y - 1 podeCriarLinhas = False ; ainda ta desenhando alguma linha EndIf If (linhaV\yFim < paredePrincipal\x + paredePrincipal\largura) linhaV\yFim = linhaV\yFim + 1 podeCriarLinhas = False ; ainda ta desenhando alguma linha EndIf Line linhaV\x,linhaV\y,linhaV\xFim,linhaV\yFim Next ; Desenhando cursor Rect cursor\x,cursor\y,cursor\largura,cursor\altura,1 ; Desenhando parede principal Rect paredePrincipal\x,paredePrincipal\y,paredePrincipal\largura,paredePrincipal\altura,0 debug() Flip Wend Function debug() Text 10,10,"MouseX: "+MouseX() Text 10,20,"MouseY: "+MouseY() Text 10,30,"Criar linhas? "+podeCriarLinhas End Function |
| ||
First, not many people on these forums can read Spanish or whatever language you are using, so it might not be easy to decode. Second, I'm not sure what jezzball is, but if it is what i think it is, then there is a blitz game sample that comes with the program called "Blitzanoid". check that out, hope it helps! |
| ||
Had to look it up, but Jezzball is like a Microsoft version of Qix. The object of the game is to paint/fill 75% of the game screen with out being touched by the Jezzball(MS) or the Spark(Qix). The clearest description of the game is here: http://takegame.com/arcade/htm/jezzball.htm @Insane Games The original Jezzball was a 28x20 grid of squares. So make an array: grid(28,20) which are all zeroes at the beginning of a game. Draw a square 28x28 pixels in your favorite color. This ensures that the playfield will fit on a 800x600 res screen. Use the "GrabImage" command to store the square as an image in memory. You have to scale the MouseX() and MouseY() coords to work with the grid() and to draw images on the screen. When the player left clicks (horizontal lines) divide the MouseX() and MouseY() locations by 28, use only the whole number result. These whole number results tell where to begin drawing your squares. Use these whole numbers as a basis for filling the grid(array) and drawing images on the screen. The code below is NOT complete, if I did it all for you what fun would that be? There should be enough code to get you started. By the way, I don't speak Portuguese, but it's close enough to Spanish to understand your code. Hope this helps, Andy sizeX% = 28 ;width of playfield sizeY% = 20 ;height of playfield square = 28 ;width and height of THE square minX% = 0 maxX% = sizeX * square minY% = 0 maxY% = sizeY * square speed = 100 ;delay in milliseconds Dim grid%(sizeX, sizeY) Graphics 800,600,0,2 SetBuffer BackBuffer() Cls ;We're drawing an image to copy here Color 255,0,255 Rect 0,0,28,28,True Color 255,0,0 Oval 0,0,28,28,True Color 255,255,255 Line 14,0,14,28 Line 15,0,15,28 Line 13,0,13,27 Line 16,1,16,27 Flip gfxSqr% = CreateImage(square,square) GrabImage(gfxSqr,0,0) MaskImage gfxSqr, 255,0,255 Cls Flip ;main loop While KeyHit(1) = 0 If MouseHit(1)=True Then mx% = MouseX() ;store in mx to lock x position my% = MouseY() ;store in my to lock y position x% = Floor(mx/square) ; x is x position in grid(array) and screen y% = Floor(my/square) ; y is y position in grid(array) and screen ;Calculate the longest x-line segment deltaX = sizeX - x If x > deltaX Then deltaX = x ;Draw a square at current position currentPosX = x * square currentPosY = y * square DrawImage(gfxSqr, currentPosX, currentPosY) ;Draw horizontal lines from current position xR% = x xL% = x For i = 1 To deltaX xR% = xR+1 xL% = xL-1 If xR <= sizeX-1 Then goRight = xR * square DrawImage(gfxSqr, goRight, currentPosY) End If If xL >= minX Then goLeft = xL * square DrawImage(gfxSqr, goLeft, currentPosY) End If Delay speed Flip Next End If If MouseHit(2)=True Then mx% = MouseX() ;store in mx to lock x position my% = MouseY() ;store in my to lock y position x% = Floor(mx/square) ; x will equal 14 y% = Floor(my/square) ; y will equal 10 ;Calculate the longest y-line segment deltaY = sizeY - y If y > deltaY Then deltaY = y ;Draw a square at current position currentPosX = x * square currentPosY = y * square DrawImage(gfxSqr, currentPosX, currentPosY) ;Draw vertical lines from current position yD = y yU = y For i% = 1 To deltaY yD = yD+1 yU = yU-1 If yD <= sizeY Then goDown = yD * square DrawImage(gfxSqr, currentPosX, goDown) End If If yU >= minY Then goUp = yU * square DrawImage(gfxSqr, currentPosX, goUp) End If Delay speed Flip Next End If Wend FreeImage(gfxSqr) End |