Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - cruelcynic

#1
GLBasic - en / array use?
2012-Jun-07
For my falling blocks game I figure I can store the block locations for my seven shapes in a 4x4 array. Do I need to make an array for all seven or is their a more efficient way to store the data?
#2
Hello. I am new to programming and really enjoying GLB. I have finished the help file tutorials and now considering what to read next. My ultimate goal is to make a new strategy rpg that plays like shining force 2. If you can recommend any tutorials or reading to get closer to that goal I would appreciate it.
#3
GLBasic - en / Pong help.
2012-Jun-04
I have worked through the Pong tutorial and the ball won't move. I can't seem to find what is wrong. Any help would be appreciated.
Code (glbasic) Select

// --------------------------------- //
// Project: Pong
// Start: Monday, June 04, 2012
// IDE Version: 10.202


GLOBAL bat_y[];DIM bat_y[2]
GLOBAL bat_x[];DIM bat_x[2]
GLOBAL score[];DIM score[2]
GLOBAL ball_x,ball_y,ball_sx,ball_sy,col

GOSUB Init
MainLoop:
GOSUB MoveAll
GOSUB ShowAll
GOTO MainLoop




// ------------------------------------------------------------- //
// ---  INIT  ---
// ------------------------------------------------------------- //
SUB Init:
GOSUB ResetBall
// Draw playfield, use as background bitmap
BLACKSCREEN
DRAWRECT 0,0,640,16, RGB(255, 255, 255)
DRAWRECT 0,464,640,480, RGB(255,255,255)
DRAWRECT 312,0,16,480,RGB(255,255,255)
USEASBMP

//reset bat y location
bat_y[0]=240; bat_y[1]=240
//reset bat x location
bat_x[0]=16; bat_x[1]=600


ENDSUB // INIT




// ------------------------------------------------------------- //
// ---  RESETBALL  ---
// ------------------------------------------------------------- //
SUB ResetBall:
LOCAL ball_sx,ball_sy
ball_x=320
ball_y=240

IF ball_sx<0
ball_sx=1
ELSE
ball_sx=-1
ENDIF

ball_sy=1


ENDSUB // RESETBALL




// ------------------------------------------------------------- //
// ---  SHOWALL  ---
// ------------------------------------------------------------- //
SUB ShowAll:
//show the bats
FOR num=0 TO 1
DRAWRECT bat_x[num],bat_y[num],16,64,RGB(255,255,255)
PRINT score[num],num*320 + 32,16
NEXT
//draw the ball
DRAWRECT ball_x,ball_y,16,16,RGB(255,255,255)
SHOWSCREEN



ENDSUB // SHOWALL




// ------------------------------------------------------------- //
// ---  MOVEALL  ---
// ------------------------------------------------------------- //
SUB MoveAll:
//paddles
FOR num=0 TO 1
//keys: A, Z
IF KEY(30) THEN bat_y[0]=bat_y[0]-2
IF KEY(44) THEN bat_y[0]=bat_y[0]+2
//keys /\,\/
IF KEY (200) THEN bat_y[1]=bat_y[1]-2
IF KEY (208) THEN bat_y[1]=bat_y[1]+2

// bat at upper/lower border?
IF bat_y[num]<0 THEN bat_y[num]=0
IF bat_y[num]>416 THEN bat_y[num]=416
NEXT
//ball
ball_x=ball_x+ball_sx
ball_y=ball_y+ball_sy
//ball at bottom
IF ball_y>464
ball_y=464
ball_sy= -ball_sy
ENDIF
//ball at ceiling
IF ball_y<0
ball_y=0
ball_sy= -ball_sy
ENDIF
//ball left border score player 1
IF ball_x<0
score[1]=score[1]+1
GOSUB ResetBall
ENDIF
//ball right border score player 0
IF ball_x>624
score[0]=score[0]+1
GOSUB ResetBall
ENDIF
FOR num=0 TO 1
IF (ball_sx<0 AND num=0) OR (ball_sx>0 AND num=1)
col=BOXCOLL (bat_x[num],bat_y[num],16,64,ball_x,ball_y,16,16)
IF col=TRUE
//turn ball speed in x direction
ball_sx=-ball_sx
//speed up ball
ball_sx=ball_sx*1.2
ball_sy=ball_sy*1.05
ENDIF
ENDIF
NEXT


ENDSUB // MOVEALL