Memory Blocks (For called in some manner)

Previous topic - Next topic

mentalthink

Hey guys I leave this code I did this past weekend... the game it's really simple but good for the brain (I'm joined to the Social Network Lumisity and I love this game. I try to done something similar for self-training)

Only copy/paste to your new project and you can play... or not  =D =D


Code (glbasic) Select
// --------------------------------- //
// Project: memory_01
// Start: Sunday, March 01, 2015
// IDE Version: 12.312

CLEARSCREEN RGB(0xb5, 0xb8, 0x42)
// SETCURRENTDIR("Media") // go to media files
SYSTEMPOINTER TRUE
GLOBAL mx,my,b1,b2
GLOBAL cell_SX = 60

GLOBAL      spr_Cell  = 100
DRAWRECT 0,0,cell_SX,cell_SX,RGB(255,254,253)
GRABSPRITE  spr_Cell ,0,0,cell_SX,cell_SX

GLOBAL      spr_Cell2 = 200
DRAWRECT    0,0,cell_SX,cell_SX,RGB(255,1,1)
GRABSPRITE  spr_Cell2 ,0,0,cell_SX,cell_SX


GLOBAL counter_Cell
GLOBAL board[]
DIM board[6][6]

GLOBAL tiempo   =   0
GLOBAL tiempo_Max = 100

initialize_Cell()
WHILE TRUE
MOUSESTATE mx,my,b1,b2



IF counter_Cell=0
initialize_Cell()
ELSE
collision_Cell ()
paint_Cell ()
ENDIF

draw_Grid ()
SHOWSCREEN
WEND

FUNCTION paint_Cell:
IF tiempo<=tiempo_Max
INC tiempo
FOR n=0 TO BOUNDS(board[],0)-1
FOR j=0 TO BOUNDS(board[],1)-1

IF board[n][j]=0
DRAWSPRITE spr_Cell  , 120+(n*cell_SX), 80+(j*cell_SX)
ELSE
// DRAWSPRITE spr_Cell2 , 120+(n*cell_SX), 80+(j*cell_SX)
ENDIF

NEXT
NEXT
ENDIF

ENDFUNCTION
FUNCTION collision_Cell:

FOR n=0 TO BOUNDS(board[],0)-1
FOR j=0 TO BOUNDS(board[],1)-1

IF BOXCOLL( mx,my, _
1,1 , _
120+(n*cell_SX), 80+(j*cell_SX) , _
cell_SX , cell_SX)

IF board[n][j]=0 AND b1
board[n][j]=1000
DEC counter_Cell
ENDIF

IF  board[n][j]<1000 AND b1
board[n][j]=2000
ENDIF

ENDIF

IF     board[n][j]=1000
DRAWSPRITE spr_Cell  , 120+(n*cell_SX), 80+(j*cell_SX)
ENDIF


NEXT
NEXT


FOR n=0 TO BOUNDS(board[],0)-1
FOR j=0 TO BOUNDS(board[],1)-1
IF    board[n][j]=2000
DRAWSPRITE spr_Cell2 , 120+(n*cell_SX), 80+(j*cell_SX)
ENDIF
NEXT
NEXT

PRINT counter_Cell ,100,100
ENDFUNCTION
FUNCTION initialize_Cell:
//Initialize Board
FOR n=0 TO BOUNDS(board[],0)-1
FOR j=0 TO BOUNDS(board[],1)-1

board[n][j]=RND(2)

IF board[n][j]=0
INC counter_Cell
ENDIF

tiempo   =   0
tiempo_Max = 200
NEXT
NEXT
ENDFUNCTION

FUNCTION draw_Grid:
FOR n=0 TO BOUNDS(board[],0)
DRAWLINE 120+(n*cell_SX),80,120+(n*cell_SX),440, RGB(1,3,1)
NEXT

FOR j=0 TO BOUNDS(board[],1)
DRAWLINE 120,80+(j*cell_SX) ,480,80+(j*cell_SX), RGB(1,3,1)
NEXT
ENDFUNCTION

erico

heeeey code from Mental! 8)

Now we are talking, let me savour this and I get back to you soon. :good:

erico

Tough game...

after a few tries, I can start managing perfections.
it does require harder concentration and attention! but it is possible on such grid.

Great stuff, the colors help too as the time it gets exposed, it burns retina enough to give a couple seconds advantage on the brain.

Cool stuff :good: now where is that grand shooter we are waiting for?? (not on the avocado tree me holps... ;/ I will beat you on release :P)

mentalthink

Thanks Erico, yep the code it's a bit dirty I did in 10 min , basically I put because I think newbie people can learn somethin of my code (you can change easily the time expose the white cubes)

About Black Sun I'm waiting for the new version of GLbasic, I have done all (I thing), the editor runs fine and when I put into the game runs fine too... I think if I take a look to the code I don't remember how works  :( ...

Thanks for comment buddy!!!  :good: