CONST true
= -1, false
= 0
electricColor
(1) = _RGB32(255)electricColor
(2) = _RGB32(50, 211, 255)
CONST totalSpecialPowers
= 6
FOR i
= 1 TO totalSpecialPowers
special(i).span = 15
CONST defaultPaddleWidth
= 100
paddleY
= _HEIGHT - blockHeight
- paddleHeight
- 1
IF lives
= 0 THEN score
= 0: lives
= 3 win = false
paused = false
generateBlocks
paddleWidth = defaultPaddleWidth
ball.state = false
ball.c
= _RGB32(161, 161, 155) ball.radius = 5
ball.xDir = right
ball.yDir = up
ball.xVel = 3
ball.yVel = 3
FOR i
= 1 TO totalSpecialPowers
special(i).start = 0
magneticOffset = paddleWidth / 2
resetParticle particle(i)
'IF k& = ASC("s") THEN special(Shooter).start = TIMER
'IF k& = ASC("m") THEN special(Magnetic).start = TIMER
'IF k& = ASC("b") THEN special(BreakThrough).start = TIMER
'IF k& = ASC("f") THEN special(FireBall).start = TIMER
'IF k& = ASC("p") THEN special(StretchPaddle).start = TIMER
'IF k& = ASC("P") THEN special(StretchPaddle2).start = TIMER
'IF k& = ASC("r") THEN EXIT DO
noFocus%% = lostFocus
paused = false
showFullScreenMessage%% = false
pauseDiff
= TIMER - pauseStart
FOR i
= 1 TO totalSpecialPowers
special(i).start = special(i).start + pauseDiff
particle(i).birth = particle(i).birth + pauseDiff
paused = true
IF noFocus%%
THEN showFullScreenMessage%%
= true
m$ = "Paused (ENTER to continue)"
IF showFullScreenMessage%%
THEN m$ = "(Hit Alt+Enter to switch to fullscreen)"
IF TIMER - special
(BreakThrough
).start
< special
(BreakThrough
).span
THEN alpha = map(ball.xVel, 3, 6, 80, 30)
alpha = 255
showBlocks
doPaddle
doBall
doParticles
m$
= "Score:" + STR$(score
) + " Lives:" + STR$(lives
)
'IF TIMER - special(FireBall).start < special(FireBall).span THEN
' _PRINTSTRING (0, 350), "fireball: " + STR$(INT(TIMER - special(FireBall).start))
'END IF
'IF TIMER - special(BreakThrough).start < special(BreakThrough).span THEN
' _PRINTSTRING (0, 370), "breakthrough: " + STR$(INT(TIMER - special(BreakThrough).start))
'END IF
'IF TIMER - special(Shooter).start < special(Shooter).span THEN
' _PRINTSTRING (0, 388), "shooter: " + STR$(INT(TIMER - special(Shooter).start))
'END IF
'IF TIMER - special(Magnetic).start < special(Magnetic).span THEN
' _PRINTSTRING (0, 406), "magnetic: " + STR$(INT(TIMER - special(Magnetic).start))
'END IF
IF TIMER - special
(StretchPaddle
).start
< special
(StretchPaddle
).span
THEN '_PRINTSTRING (0, 422), "stretch: " + STR$(INT(TIMER - special(StretchPaddle).start))
paddleWidth = defaultPaddleWidth * 1.5
paddleWidth = defaultPaddleWidth
IF TIMER - special
(StretchPaddle2
).start
< special
(StretchPaddle2
).span
THEN '_PRINTSTRING (0, 438), "stretch2: " + STR$(INT(TIMER - special(StretchPaddle2).start))
paddleWidth = defaultPaddleWidth * 2
IF TIMER - special
(StretchPaddle
).start
> special
(StretchPaddle
).span
OR special
(StretchPaddle
).start
= 0 THEN paddleWidth = defaultPaddleWidth
PRINT "Good job, you win."
Focused = false
lostFocus%% = true
Focused = true
IF particle
(i
).lifeSpan
> 0 AND TIMER - particle
(i
).birth
> particle
(i
).lifeSpan
THEN particle
(i
).state
= false:
_CONTINUE
'move
particle(i).xVel = particle(i).xVel + particle(i).xAcc
particle(i).yVel = particle(i).yVel + particle(i).yAcc + gravity
particle(i).x = particle(i).x + particle(i).xVel
particle(i).y = particle(i).y + particle(i).yVel
IF particle
(i
).kind
= bullet
THEN l = newParticle
particle
(l
).r
= 222 + (RND * 30) particle
(l
).g
= 100 + (RND * 70) particle(l).x = particle(i).x
particle(l).y = particle(i).y
particle(l).lifeSpan = 0.05
'check visibility
IF particle
(i
).x
- particle
(i
).size
/ 2 < 0 OR particle
(i
).x
+ particle
(i
).size
/ 2 > _WIDTH OR particle
(i
).y
- particle
(i
).size
/ 2 < 0 OR particle
(i
).y
+ particle
(i
).size
/ 2 > _HEIGHT THEN particle(i).state = false
'show
IF particle
(i
).lifeSpan
> 0 THEN alpha
= map
(TIMER - particle
(i
).birth
, 0, particle
(i
).lifeSpan
, 255, 0) alpha = 255
thisColor
= _RGBA32(particle
(i
).r
, particle
(i
).g
, particle
(i
).b
, alpha
)
CircleFill particle(i).x, particle(i).y, particle(i).size, thisColor
LINE (particle
(i
).x
- size
/ 2, particle
(i
).y
- size
/ 2)-STEP(particle
(i
).size
, particle
(i
).size
), thisColor
, BF
'CONST FireBall = 1
'CONST Shooter = 2
'CONST BreakThrough = 3
'CONST Magnetic = 4
'CONST StretchPaddle = 5
'CONST StretchPaddle2 = 6
l = newParticle
particle
(l
).r
= 222 + (RND * 30) particle
(l
).g
= 100 + (RND * 70) particle
(l
).x
= particle
(i
).x
+ COS(RND * _PI(2)) * (ball.radius
* RND) particle
(l
).y
= particle
(i
).y
+ SIN(RND * _PI(2)) * (ball.radius
* RND) particle(l).lifeSpan = .1
CircleFill particle
(i
).x
, particle
(i
).y
, particle
(i
).size
, _RGBA32(222 + (RND * 30), 100 + (RND * 70), 0, RND * 255) specialDrawn = true
LINE (particle
(i
).x
- 7, particle
(i
).y
+ 1)-STEP(15, 8), _RGB32(89, 161, 255), BF
CircleFill particle
(i
).x
- 7, particle
(i
).y
+ 5, 4, _RGB32(194, 89, 61) CircleFill particle
(i
).x
- 7, particle
(i
).y
+ 2, 3, _RGB32(194, 133, 61) CircleFill particle
(i
).x
- 7, particle
(i
).y
, 3, _RGB32(194, 188, 61)
l = newParticle
particle
(l
).r
= 222 + (RND * 30) particle
(l
).g
= 100 + (RND * 70) particle(l).x = particle(i).x - 7
particle(l).y = particle(i).y
particle(l).lifeSpan = .1
specialDrawn = true
CircleFill particle
(i
).x
- 8, particle
(i
).y
+ 8, 3, _RGB32(177, 30) CircleFill particle
(i
).x
- 6, particle
(i
).y
+ 6, 3, _RGB32(177, 50) CircleFill particle
(i
).x
- 3, particle
(i
).y
+ 3, 4, _RGB32(177, 100) CircleFill particle
(i
).x
, particle
(i
).y
, 4, _RGB32(177, 200) specialDrawn = true
PSET (particle
(i
).x
+ COS(0) * (particle
(i
).size
+ particle
(i
).size
* RND), particle
(i
).y
+ SIN(0) * (particle
(i
).size
+ particle
(i
).size
* RND)), electricColor
(j
) LINE -(particle
(i
).x
+ COS(k
) * (particle
(i
).size
+ particle
(i
).size
* RND), particle
(i
).y
+ SIN(k
) * (particle
(i
).size
+ particle
(i
).size
* RND)), electricColor
(j
) LINE -(particle
(i
).x
+ COS(0) * (particle
(i
).size
+ particle
(i
).size
* RND), particle
(i
).y
+ SIN(0) * (particle
(i
).size
+ particle
(i
).size
* RND)), electricColor
(j
) specialDrawn = true
LINE (particle
(i
).x
- 7, particle
(i
).y
+ 1)-STEP(15, 8), _RGB32(89, 161, 255), BF
CircleFill particle
(i
).x
- 7, particle
(i
).y
+ 5, 4, _RGB32(194, 89, 61) _PRINTSTRING (particle
(i
).x
- 16, particle
(i
).y
- 10), "1.5x" specialDrawn = true
LINE (particle
(i
).x
- 3, particle
(i
).y
+ 1)-STEP(15, 8), _RGB32(89, 161, 255), BF
CircleFill particle
(i
).x
- 3, particle
(i
).y
+ 5, 4, _RGB32(194, 89, 61) specialDrawn = true
PSET (particle
(i
).x
, particle
(i
).y
), thisColor
'check collision with paddle if this particle contains a special power
'IF specialDrawn = false THEN
' m$ = LTRIM$(STR$(particle(i).special))
' COLOR _RGB32(0)
' _PRINTSTRING (particle(i).x + 1, particle(i).y + 1), m$
' COLOR _RGB32(255)
' _PRINTSTRING (particle(i).x, particle(i).y), m$
'END IF
IF particle
(i
).x
- particle
(i
).size
/ 2 > paddleX
AND particle
(i
).x
+ particle
(i
).size
/ 2 < paddleX
+ paddleWidth
AND particle
(i
).y
+ particle
(i
).size
/ 2 >= paddleY
THEN particle(i).state = false
special
(particle
(i
).special
).start
= TIMER
'check collision with blocks if this particle is a bullet
IF particle
(i
).kind
= bullet
THEN IF particle
(i
).x
> block
(j
).x
AND particle
(i
).x
< block
(j
).x
+ blockWidth
AND particle
(i
).y
< block
(j
).y
+ blockHeight
THEN destroyBlock j, false
IF TIMER - special
(BreakThrough
).start
> special
(BreakThrough
).span
OR special
(BreakThrough
).start
= 0 THEN particle(i).state = false
SUB resetParticle
(this
AS Particle
) this = empty
b = b + 1
block(b).x = (i - 1) * blockWidth
block(b).y = (j - 1) * blockHeight
minRGB = 50
block
(b
).c
= _RGB32(red
, green
, blue
) block
(b
).special
= RND * totalSpecialPowers
activeBlocks = activeBlocks + 1
IF block
(i
).kind
<> unbreakable
THEN LINE (block
(i
).x
, block
(i
).y
)-STEP(blockWidth
- 1, blockHeight
- 1), block
(i
).c
, BF
IF block
(i
).kind
= hitTwice
THEN FOR x
= block
(i
).x
TO block
(i
).x
+ blockWidth
- 1 STEP 5 LINE (x
, block
(i
).y
)-(x
, block
(i
).y
+ blockHeight
- 1), _RGB32(188) activeBlocks = activeBlocks - 1
FOR x
= block
(i
).x
TO block
(i
).x
+ blockWidth
- 1 STEP 5 LINE (x
, block
(i
).y
)-(x
, block
(i
).y
+ blockHeight
- 1), _RGB32(72) FOR y
= block
(i
).y
TO block
(i
).y
+ blockHeight
- 1 STEP 5 LINE (block
(i
).x
, y
)-(block
(i
).x
+ blockWidth
- 1, y
), _RGB32(72)
LINE (block
(i
).x
, block
(i
).y
)-STEP(blockWidth
- 1, blockHeight
- 1), _RGB32(255), B
LINE (block
(i
).x
+ 1, block
(i
).y
+ 1)-STEP(blockWidth
- 3, blockHeight
- 3), _RGB32(0), B
'COLOR _RGB32(0)
'_PRINTSTRING (block(i).x + 1, block(i).y + 1), STR$(block(i).special)
'COLOR _RGB32(255)
'_PRINTSTRING (block(i).x, block(i).y), STR$(block(i).special)
LINE (block
(i
).x
+ j
, block
(i
).y
+ j
)-STEP(blockWidth
- j
* 2, blockHeight
- j
* 2), _RGB32(255, 166, 0), B
LINE (block
(i
).x
+ j
, block
(i
).y
+ j
)-STEP(blockWidth
- j
* 2, blockHeight
- j
* 2), _RGB32(255, 238, 0), B
win = (activeBlocks = 0)
paddleX
= _MOUSEX - paddleWidth
/ 2
IF paddleX
< 0 THEN paddleX
= 0
LINE (paddleX
+ paddleHeight
/ 2, paddleY
)-STEP(paddleWidth
- paddleHeight
, paddleHeight
), _RGB32(89, 161, 255), BF
CircleFill paddleX
+ paddleHeight
/ 2, paddleY
+ paddleHeight
/ 2, paddleHeight
/ 2, _RGB32(194, 89, 61) CircleFill paddleX
+ paddleWidth
- paddleHeight
/ 2, paddleY
+ paddleHeight
/ 2, paddleHeight
/ 2, _RGB32(194, 89, 61)
IF TIMER - special
(Magnetic
).start
< special
(Magnetic
).span
THEN PSET (paddleX
+ paddleHeight
/ 2, paddleY
), electricColor
(j
) FOR i
= paddleX
+ paddleHeight
TO paddleX
+ paddleWidth
- paddleHeight
STEP paddleWidth
/ 10 LINE -(i
, paddleY
- (RND * 10)), electricColor
(j
) LINE -(paddleX
+ paddleWidth
- paddleHeight
/ 2, paddleY
), electricColor
(j
)
mouseWasDown = true
IF TIMER - special
(Shooter
).start
< special
(Shooter
).span
THEN CircleFill paddleX
+ paddleHeight
/ 2, paddleY
, paddleHeight
/ 3, _RGB32(194, 133, 61) CircleFill paddleX
+ paddleWidth
- paddleHeight
/ 2, paddleY
, paddleHeight
/ 3, _RGB32(194, 133, 61)
CircleFill paddleX
+ paddleHeight
/ 2, paddleY
- paddleHeight
/ 4, paddleHeight
/ 4, _RGB32(194, 188, 61) CircleFill paddleX
+ paddleWidth
- paddleHeight
/ 2, paddleY
- paddleHeight
/ 4, paddleHeight
/ 4, _RGB32(194, 188, 61)
mouseWasDown = false
l = newParticle
particle(l).r = 100
particle(l).g = 100
particle(l).b = 100
IF i
= 1 THEN particle
(l
).x
= paddleX
+ paddleHeight
/ 2 ELSE particle
(l
).x
= paddleX
+ paddleWidth
- paddleHeight
/ 2 particle(l).y = paddleY
particle(l).yVel = -4.5
particle(l).yAcc = -gravity * 1.5
particle(l).size = 2
particle(l).kind = bullet
ball.x = paddleX + magneticOffset
ball.y = paddleY - (ball.radius)
ball.x = ball.x + ball.xDir * ball.xVel
ball.y = ball.y + ball.yDir * ball.yVel
ballCollision
IF TIMER - special
(FireBall
).start
< special
(FireBall
).span
THEN l = newParticle
particle
(l
).r
= 222 + (RND * 30) particle
(l
).g
= 100 + (RND * 70) particle
(l
).x
= ball.x
+ COS(RND * _PI(2)) * (ball.radius
* RND) particle
(l
).y
= ball.y
+ SIN(RND * _PI(2)) * (ball.radius
* RND) particle
(l
).lifeSpan
= RND
CircleFill ball.x, ball.y, ball.radius, ball.c
IF particle
(i
).state
= false
THEN newParticle& = i
resetParticle particle(i)
particle(i).state = true
particle
(i
).birth
= TIMER
'paddle
IF ball.x
> paddleX
AND ball.x
< paddleX
+ paddleWidth
AND ball.y
> paddleY
AND ball.y
< paddleY
+ paddleHeight
THEN IF TIMER - special
(Magnetic
).start
< special
(Magnetic
).span
THEN ball.state = false
magneticOffset = ball.x - paddleX
IF ball.x
< paddleX
+ paddleWidth
/ 2 THEN ball.xDir = left
ball.xVel = map(ball.x, paddleX, paddleX + paddleWidth / 3, 6, 3)
ball.xDir = right
ball.xVel = map(ball.x, paddleX + paddleWidth / 3, paddleX + paddleWidth, 3, 6)
IF ball.xVel
< 3 THEN ball.xVel
= 3
IF ball.yDir
= 1 AND ball.y
< paddleY
+ paddleHeight
/ 2 THEN ball.yDir
= -1
'blocks
IF ball.x
> block
(i
).x
AND ball.x
< block
(i
).x
+ blockWidth
AND ball.y
> block
(i
).y
AND ball.y
< block
(i
).y
+ blockHeight
THEN destroyBlock i, true
'walls
IF ball.x
< ball.radius
THEN ball.xDir
= right
lives = lives - 1
magneticOffset = paddleWidth / 2
ball.state = false
ball.xDir = right
ball.yDir = up
ball.xVel = 3
ball.yVel = 3
IF ball.y
< 0 THEN ball.yDir
= down
block(i).state = false
IF TIMER - special
(BreakThrough
).start
< special
(BreakThrough
).span
THEN maxJ = 10
maxK = 3
l = newParticle
particle
(l
).r
= _RED32(block
(i
).c
) particle
(l
).b
= _BLUE32(block
(i
).c
) particle(l).r = map(a, 0, 1000, 50, 255)
particle(l).g = map(a, 0, 1000, 50, 255)
particle(l).b = map(a, 0, 1000, 50, 255)
particle(l).x = block(i).x + ((blockWidth / maxJ) * (j - 1))
particle(l).y = block(i).y + ((blockHeight / maxK) * (k - 1))
particle
(l
).xAcc
= COS(map
(a
, 0, 1, _PI(1.5), _PI(2))) particle
(l
).yAcc
= SIN(map
(a
, 0, 1, _PI(1.5), _PI(2))) particle
(l
).xAcc
= COS(map
(a
, 0, 1, 0, _PI(.5))) particle
(l
).yAcc
= SIN(map
(a
, 0, 1, 0, _PI(.5))) particle
(l
).xAcc
= COS(map
(a
, 0, 1, _PI, _PI(1.5))) particle
(l
).yAcc
= SIN(map
(a
, 0, 1, _PI, _PI(1.5))) particle
(l
).xAcc
= COS(map
(a
, 0, 1, _PI(.5), _PI)) particle
(l
).yAcc
= SIN(map
(a
, 0, 1, _PI(.5), _PI)) particle(l).lifeSpan = .5
particle(l).size = 1
l = newParticle
particle(l).size = 6
particle(l).x = block(i).x + blockWidth / 2
particle(l).y = block(i).y + blockHeight / 2
particle(l).r = 255
particle(l).g = 255
particle(l).b = 255
particle(l).kind = specialPower
particle(l).special = block(i).special
score = score + points
block(i).kind = regular
IF TIMER - special
(FireBall
).start
< special
(FireBall
).span
THEN destroyBlock i
, ballHit
'check if the ball is trapped between two unbreakable blocks
lastBlock(3) = lastBlock(2)
lastBlock(2) = lastBlock(1)
lastBlock(1) = block(i)
IF (lastBlock
(1).x
= lastBlock
(3).x
AND lastBlock
(1).y
= lastBlock
(3).y
) OR _
lastBlock
(1).x
= lastBlock
(2).x
AND lastBlock
(1).y
= lastBlock
(2).y
THEN ball.xVel = 6
ball.xVel = 5
ball.xVel = 3
ball.xVel = 4
IF (block
(i
).kind
= unbreakable
OR block
(i
).kind
= hitTwice
) THEN FOR j
= 1 TO map
(ball.xVel
, 3, 6, 10, 30) l = newParticle
particle
(l
).r
= 222 + (RND * 30) particle
(l
).g
= 100 + (RND * 70) particle
(l
).x
= ball.x
+ COS(RND * _PI(2)) * (ball.radius
* RND) particle
(l
).y
= ball.y
+ SIN(RND * _PI(2)) * (ball.radius
* RND) particle
(l
).lifeSpan
= RND
particle
(l
).xVel
= COS(map
(a
, 0, 1, _PI(1.5), _PI(2))) particle
(l
).yVel
= SIN(map
(a
, 0, 1, _PI(1.5), _PI(2))) particle
(l
).xVel
= COS(map
(a
, 0, 1, 0, _PI(.5))) particle
(l
).yVel
= SIN(map
(a
, 0, 1, 0, _PI(.5))) particle
(l
).xVel
= COS(map
(a
, 0, 1, _PI, _PI(1.5))) particle
(l
).yVel
= SIN(map
(a
, 0, 1, _PI, _PI(1.5))) particle
(l
).xVel
= COS(map
(a
, 0, 1, _PI(.5), _PI)) particle
(l
).yVel
= SIN(map
(a
, 0, 1, _PI(.5), _PI))
IF TIMER - special
(BreakThrough
).start
> special
(BreakThrough
).span
OR special
(BreakThrough
).start
= 0 THEN IF ball.x
< block
(i
).x
+ blockWidth
/ 2 THEN ball.xDir
= left
ELSE ball.xDir
= right
IF ball.y
< block
(i
).y
+ blockHeight
/ 2 THEN ball.yDir
= up
ELSE ball.yDir
= down
' CX = center x coordinate
' CY = center y coordinate
' R = radius
' C = fill color
RadiusError = -Radius
X = Radius
Y = 0
LINE (CX
- X
, CY
)-(CX
+ X
, CY
), C
, BF
RadiusError = RadiusError + Y * 2 + 1
LINE (CX
- Y
, CY
- X
)-(CX
+ Y
, CY
- X
), C
, BF
LINE (CX
- Y
, CY
+ X
)-(CX
+ Y
, CY
+ X
), C
, BF
X = X - 1
RadiusError = RadiusError - X * 2
Y = Y + 1
LINE (CX
- X
, CY
- Y
)-(CX
+ X
, CY
- Y
), C
, BF
LINE (CX
- X
, CY
+ Y
)-(CX
+ X
, CY
+ Y
), C
, BF
FUNCTION map!
(value!
, minRange!
, maxRange!
, newMinRange!
, newMaxRange!
) map! = ((value! - minRange!) / (maxRange! - minRange!)) * (newMaxRange! - newMinRange!) + newMinRange!