balldemo (a simple breakout game) by Matt McFarland28th Nov 2003 16:40
|
---|
Summary a break-out style game, mainly just my first game. Description This is the first game I ever made, is has been a learning experience. Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com Rem Project: sprite collision Rem Created: 11/28/2003 3:34:23 PM Rem ***** Main Source File ***** load image "ball.png",1 load image "square.png",2 load image "paddle.png",3 `sprites 1 to 312 are blocks for X = 10 to 610 step 24 for Y = 1 to 280 step 24 INC I sprite I,X,Y,2 next Y next X sync rate 100 ballx = screen width() / 2 bally = screen height() / 2 + 100 ballspeedX = 2 ballspeedY = 2 do sprite 313,mousex(),440,3 sprite 314,ballx,bally,1 for i = 1 to 312 if sprite collision(314,i) = 1 then ballspeedY= ballspeedY * -1 : delete sprite i next i if ballX <= 1 then ballspeedX = ballspeedX * -1 if ballX >= 639 then ballspeedX = ballspeedX * -1 if ballY <= 1 then ballspeedY = ballspeedY * -1 if sprite collision (313,314) = 1 then ballspeedY=ballspeedY * -1 ballx=ballx+ballspeedX bally=bally+ballspeedY if bally > 500 then wait key : lives = lives - 1 : ballx=0:bally=0:gosub redrawball loop redrawball: ballx = screen width() / 2 bally = screen height() / 2 + 100 ballspeedX = 2 ballspeedY = 2 return |