I have a problem that when all the blocks on level 1 are destroyed, and the second level is started the Balls position is left off where the ball left off from lv 1. This is terrible because when lv 2 appears like 5 blocks are destroyed automatically because of the balls position. I know this sounds extremely easy to fix but I have tried everything that I could think of that would fix this.
Here is the download link to my full game with all the media.
http://www.angelfire.com/games5/db_games/BlockOut.zip
sync on
sync rate 40
hide mouse
load image "player.bmp",1
load image "my_ball.bmp",2
load image "border_1.bmp",3
load image "border_2.bmp",4
load image "goal.bmp",5
load image "brick_1.bmp",6
load image "brick_2.bmp",7
load image "brick_3.bmp",8
load image "brick_4.bmp",9
load music "dodge this.mid", 1
load sound "thump.wav",1
load sound "bounce.wav",2
load sound "dropped.wav",3
load sound "getready.wav",4
play music 1
loop music 1
play sound 4
sprite 3,105,25,3
sprite 4,105,380,5
sprite 5,105,50,4
sprite 6,500,50,4
sprite 28, 190,75,6
sprite 29, 240,75,7
sprite 30, 340,75,8
sprite 31, 390,75,6
`sprite 32 is in the middle of sprites 28 - 32
sprite 32, 290,75,9
sprite 7, 140,100,6
sprite 8, 190,100,6
sprite 9, 240,100,6
sprite 10, 340,100,6
sprite 11, 390,100,6
sprite 12, 440,100,6
` sprite 13 is in the middle of sprites 7-13
sprite 13, 290,100,9
sprite 14, 140,125,7
sprite 15, 190,125,7
sprite 16, 240,125,7
sprite 17, 340,125,7
sprite 18, 390,125,7
sprite 19, 440,125,7
` sprite 20 is in the middle of sprites 14-20
sprite 20, 290,125,9
sprite 21, 140,150,8
sprite 22, 190,150,8
sprite 23, 240,150,8
sprite 24, 290,150,8
sprite 25, 340,150,8
sprite 26, 390,150,8
sprite 27, 440,150,8
player_x = 320
player_y = 340
ball_x = 320
ball_y = 330
ball_speed = 5
ballx_dir = rnd(1)
bally_dir = 1
new_level = 0
lives = 3
player_score = 0
set text opaque
text 1,1, "Player Score: 0"
text 280,1, "Block Out"
text 520,1, "Player Lives: 3"
Do
if leftkey() = 1 then player_x = player_x - 10
if rightkey() = 1 then player_x = player_x + 10
` 0 on x = left
` 1 on x = right
` 0 on y = up
` 1 on y = down
if ballx_dir = 0 then DEC ball_x, ball_speed
if ballx_dir = 1 then INC ball_x, ball_speed
if bally_dir = 1 then INC ball_y, ball_speed
if bally_dir = 0 then DEC ball_y, ball_speed
if ball_y < 50 then bally_dir = 1 : play sound 2
if ball_y > 400 then lives = lives - 1: text 520,1, "Player Lives: " + str$(lives): delete sprite 2: set_ball = 1 : play sound 3
if ball_x < 135 then ballx_dir = 1 : play sound 1
if ball_x > 480 then ballx_dir = 0 : play sound 1
if player_x < 130 then player_x = 130
if player_x > 460 then player_x = 460
sprite 1, player_x,player_y,1
sprite 2, ball_x,ball_y,2
if sprite hit(1,2) then bally_dir = 0 : play sound 2
for brick_1 = 7 to 12
if sprite hit(brick_1,2) = 1 then delete sprite (brick_1) : new_lv = new_lv + 1 : bally_dir = 1 : ballx_dir = rnd(1) : player_score = player_score + 5 : text 1,1, "Player Score: " + Str$(player_score): play sound 2
next brick_1
for brick_2 = 14 to 19
if sprite hit(brick_2,2) = 1 then delete sprite (brick_2) : new_lv = new_lv + 1 : bally_dir = 1 : ballx_dir = rnd(1) : player_score = player_score + 6 : text 1,1, "Player Score: " + Str$(player_score): play sound 2
next brick_2
for brick_3 = 20 to 27
if sprite hit(brick_3,2) = 1 then delete sprite (brick_3) : new_lv = new_lv + 1 : bally_dir = 1 : ballx_dir = rnd(1) : player_score = player_score + 7 : text 1,1, "Player Score: " + Str$(player_score): play sound 2
next brick_3
for brick_4 = 28 to 31
if sprite hit(brick_4,2) = 1 then delete sprite (brick_4) : new_lv = new_lv + 1 : bally_dir = 1 : ballx_dir = rnd(1) : player_score = player_score + 8 : text 1,1, "Player Score: " + Str$(player_score) : play sound 2
next brick_4
if sprite hit(13,2) = 1 then delete sprite 13 : new_lv = new_lv + 1 : bally_dir = 1 : ballx_dir = rnd(1) : ball_speed = ball_speed + 1: player_score = player_score + 15 : text 1,1, "Player Score: " + Str$(player_score) : play sound 2
if sprite hit(20,2) = 1 then delete sprite 20 : new_lv = new_lv + 1 : bally_dir = 1 : ballx_dir = rnd(1) : ball_speed = ball_speed + 1: player_score = player_score + 15 : text 1,1, "Player Score: " + Str$(player_score) : play sound 2
if sprite hit(32,2) = 1 then delete sprite 32 : new_lv = new_lv + 1 : bally_dir = 1 : ballx_dir = rnd(1) : ball_speed = ball_speed + 1: player_score = player_score + 15 : text 1,1, "Player Score: " + Str$(player_score) : play sound 2
if lives < 1 then text 280,240, "Game Over" : end
if new_lv = 26
pos_ball = 1
sprite 2, ball_x,ball_y,2
sprite 33, Xpos(1),Ypos(1),8
sprite 34, Xpos(2),Ypos(2),8
sprite 35, Xpos(3),Ypos(3),8
sprite 36, Xpos(5),Ypos(5),8
sprite 37, Xpos(6),Ypos(6),8
sprite 38, Xpos(7),Ypos(7),8
`sprite in middle
sprite 39, Xpos(4),Ypos(4),9
sprite 40, Xpos(8),Ypos(8),7
sprite 41, Xpos(9),Ypos(9),7
sprite 42, Xpos(10),Ypos(10),7
sprite 43, Xpos(12),Ypos(12),7
sprite 44, Xpos(13),Ypos(13),7
sprite 45, Xpos(14),Ypos(14),7
` sprite 20 is in the middle of sprites 40-46
sprite 46, Xpos(11),Ypos(11),9
sprite 47, Xpos(15),Ypos(15),6
sprite 48, Xpos(16),Ypos(16),6
sprite 49, Xpos(17),Ypos(17),6
sprite 50, Xpos(19),Ypos(19),6
sprite 51, Xpos(20),Ypos(20),6
sprite 52, Xpos(21),Ypos(21),6
` sprite 13 is in the middle of sprites 47-53
sprite 53, Xpos(18),Ypos(18),9
sprite 54, Xpos(22),Ypos(22),6
sprite 55, Xpos(23),Ypos(23),7
sprite 56, Xpos(25),Ypos(25),8
sprite 57, Xpos(26),Ypos(26),6
`sprite 32 is in the middle of sprites 28 - 32
sprite 58, Xpos(24),Ypos(24),9
dim XPos(26)
`Sprite 33 - 39
XPos(1) = 140
XPos(2) = 190
XPos(3) = 240
`Sprite 39
XPos(4) = 290
XPos(5) = 340
XPos(6) = 390
XPos(7) = 440
`Sprites 40 - 46
XPos(8) = 140
XPos(9) = 190
XPos(10) = 240
`Sprite 46
XPos(11) = 290
XPos(12) = 340
XPos(13) = 390
XPos(14) = 440
`Sprites 47 - 53
XPos(15) = 140
XPos(16) = 190
XPos(17) = 240
`Sprite 53
XPos(18) = 290
XPos(19) = 340
XPos(20) = 390
XPos(21) = 440
`Sprites 54 - 58
XPos(22) = 190
XPos(23) = 240
`Sprite 58
XPos(24) = 290
XPos(25) = 340
XPos(26) = 390
Dim YPos(26)
YPos(1) = 150
YPos(2) = 150
YPos(3) = 150
`Sprite 39
YPos(4) = 150
YPos(5) = 150
YPos(6) = 150
YPos(7) = 150
YPos(8) = 125
YPos(9) = 125
YPos(10) = 125
YPos(11) = 125
YPos(12) = 125
YPos(13) = 125
YPos(14) = 125
YPos(15) = 100
YPos(16) = 100
YPos(17) = 100
YPos(18) = 100
YPos(19) = 100
YPos(20) = 100
YPos(21) = 100
YPos(22) = 75
YPos(23) = 75
YPos(24) = 75
YPos(25) = 75
YPos(26) = 75
pos_ball = 0
play sound 4
`For Brick set 1
for BS1 = 33 to 39
if sprite hit(BS1,2) = 1
delete sprite BS1
GameDone = GameDone + 1
bally_dir = 1
ballx_dir = rnd(1)
player_score = player_score + 5
text 1,1, "Player Score: " + Str$(player_score)
play sound 2
if BS1 = 33 then B33 = 1
if BS1 = 34 then B34 = 1
if BS1 = 35 then B35 = 1
if BS1 = 36 then B36 = 1
if BS1 = 37 then B37 = 1
if BS1 = 38 then B38 = 1
if BS1 = 39 then B39 = 1
endif
next BS1
if B33 = 1
delete sprite 33
Xpos(1) = 640
Ypos(1) = 480
endif
if B34 = 1
delete sprite 34
Xpos(2) = 640
Ypos(2) = 480
endif
if B35 = 1
delete sprite 35
Xpos(3) = 640
Ypos(3) = 480
endif
if B36 = 1
delete sprite 36
Xpos(5) = 640
Ypos(5) = 480
endif
if B37 = 1
delete sprite 37
Xpos(6) = 640
Ypos(6) = 480
endif
if B38 = 1
delete sprite 38
Xpos(7) = 640
Ypos(7) = 480
endif
if B39 = 1
delete sprite 39
Xpos(4) = 640
Ypos(4) = 480
endif
`Second Row of Bricks
for BS2 = 40 to 46
if sprite hit(BS2,2) = 1
delete sprite BS2
GameDone = GameDone + 1
bally_dir = 1
ballx_dir = rnd(1)
player_score = player_score + 7
text 1,1, "Player Score: " + Str$(player_score)
play sound 2
if BS2 = 40 then B40 = 1
if BS2 = 41 then B41 = 1
if BS2 = 42 then B42 = 1
if BS2 = 43 then B43 = 1
if BS2 = 44 then B44 = 1
if BS2 = 45 then B45 = 1
if BS2 = 46 then B46 = 1
endif
next BS2
if B40 = 1
delete sprite 40
Xpos(8) = 640
Ypos(8) = 480
endif
if B41 = 1
delete sprite 41
Xpos(9) = 640
Ypos(9) = 480
endif
if B42 = 1
delete sprite 42
Xpos(10) = 640
Ypos(10) = 480
endif
if B43 = 1
delete sprite 43
Xpos(12) = 640
Ypos(12) = 480
endif
if B44 = 1
delete sprite 44
Xpos(13) = 640
Ypos(13) = 480
endif
if B45 = 1
delete sprite 45
Xpos(14) = 640
Ypos(14) = 480
endif
if B46 = 1
delete sprite 46
Xpos(11) = 640
Ypos(11) = 480
endif
`Third Row of Bricks
for BS3 = 47 to 53
if sprite hit(BS3,2) = 1
delete sprite BS3
GameDone = GameDone + 1
bally_dir = 1
ballx_dir = rnd(1)
player_score = player_score + 7
text 1,1, "Player Score: " + Str$(player_score)
play sound 2
if BS3 = 47 then B47 = 1
if BS3 = 48 then B48 = 1
if BS3 = 49 then B49 = 1
if BS3 = 50 then B50 = 1
if BS3 = 51 then B51 = 1
if BS3 = 52 then B52 = 1
if BS3 = 53 then B53 = 1
endif
next BS3
if B47 = 1
delete sprite 47
Xpos(15) = 640
Ypos(15) = 480
endif
if B48 = 1
delete sprite 48
Xpos(16) = 640
Ypos(16) = 480
endif
if B49 = 1
delete sprite 49
Xpos(17) = 640
Ypos(17) = 480
endif
if B50 = 1
delete sprite 50
Xpos(19) = 640
Ypos(19) = 480
endif
if B51 = 1
delete sprite 51
Xpos(20) = 640
Ypos(20) = 480
endif
if B52 = 1
delete sprite 52
Xpos(21) = 640
Ypos(21) = 480
endif
if B53 = 1
delete sprite 53
Xpos(18) = 640
Ypos(18) = 480
endif
`Last Row
for BS4 = 54 to 58
if sprite hit(BS4,2) = 1
delete sprite BS4
GameDone = GameDone + 1
bally_dir = 1
ballx_dir = rnd(1)
player_score = player_score + 10
text 1,1, "Player Score: " + Str$(player_score)
play sound 2
if BS4 = 54 then B54 = 1
if BS4 = 55 then B55 = 1
if BS4 = 56 then B56 = 1
if BS4 = 57 then B57 = 1
if BS4 = 58 then B58 = 1
endif
next BS4
if B54 = 1
delete sprite 54
Xpos(22) = 640
Ypos(22) = 480
endif
if B55 = 1
delete sprite 55
Xpos(23) = 640
Ypos(23) = 480
endif
if B56 = 1
delete sprite 56
Xpos(25) = 640
Ypos(25) = 480
endif
if B57 = 1
delete sprite 57
Xpos(26) = 640
Ypos(26) = 480
endif
if B58 = 1
delete sprite 58
Xpos(24) = 640
Ypos(24) = 480
endif
endif
if GameDone = 26
set text size 20
center text 280,240, "You Have Completed the game with a Score of"
center text 280,270, "Score : " + Str$(player_score)
sleep 2000
end
endif
if set_ball = 1
sleep 1000
ball_x = 320
ball_y = 330
ballx_dir = rnd(1)
bally_dir = 0
set_ball = 0
endif
if pos_ball = 1
delete sprite 2
sleep 1000
ball_x = 320
ball_y = 330
ballx_dir = rnd(1)
bally_dir = 0
endif
sync
loop