Thanks for the posts. The help is much appreciated!
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 MenuGLOBAL BlockColor[];DIM BlockColor[7][3]//rgb colors(1-3) for each of the seven pieces
FOR iter = 0 TO 6 //loop through seven pieces
READ BlockColor[iter][0]//read red amount
READ BlockColor[iter][1]//read green amount
READ BlockColor[iter][2]//read blue amount
NEXT
DATA 255,255,0//yellow square
DATA 0,128,255//turquoise line
DATA 0,0,255//blue left L
DATA 255,128,0//orange right L
DATA 255,0,0//red left S
DATA 0,255,0//green right S
DATA 128,0,255//purple T
// --------------------------------- //
// 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
Quote from: erico on 2012-Jun-01I put some time in today and got the onemore tutorial game built. I wish the tutorial included defining the variables, but I figured it out and the game worked like a charm. Hell of a neat program.
@cruelcynic, It can be more then a hobbyist tool, some skilled coders here make a living with it. As for learning it, it depends if you actually want to, but first time users have always managed to impress on what they can pull out after a few hours on it.