@CompSciStu Said
I decided to make Brick Breaker for a school project and so far I have what I estimate to be about half of what I need.
breed [ paddles paddle ]
breed [balls ball]
breed [blocks block ]
globals [ score lives ]
to setup
ca
create-balls 1
ask balls [ ball-setup ]
draw-paddle
create-level
set lives 5
set score 0
end
to draw-paddle
ask patches with [ pxcor = -2 or pxcor = -1 or pxcor = 0 or pxcor = 1 or pxcor = 2 and pycor = min-pycor ] [ sprout-paddles 1]
ask paddles [ setup-paddles ]
end
to setup-paddles
set color white
set heading 0
set shape "paddle"
end
to ball-setup
set heading 45
set shape "circle"
set color red
setxy 0 (min-pycor + 1)
end
to setup-blocks
set color blue
set shape "square"
end
to create-level
ask patches with [ abs pycor < 2 and abs pxcor < 14 ] [ sprout-blocks 1]
ask blocks [setup-blocks]
end
to begin-bouncing
fd 1
if any? paddles-on patch-ahead 1 and [who] of paddles = 3 or [who] of paddles = 4
[ set heading (- heading)
fd 0.01]
if any? paddles-on patch-ahead 1 and [who] of paddles = 2 or [who] of paddles = 1
[ set heading -60
fd 0.01]
if any? paddles-on patch-ahead 1 and [who] of paddles = 5
[ set heading -90
fd 0.01]
if any? blocks-here
[ set heading (180 - heading)
ask blocks-here [die]
set score score + 10]
if abs [pxcor] of patch-ahead 1 = max-pxcor
[ set heading (- heading)
]
if abs [pycor] of patch-ahead 1 = max-pycor
[ set heading (180 - heading)
]
wait 0.1
end
to move-paddle-left
if [pxcor] of one-of paddles != min-pxcor
[ask paddles [ setxy (pxcor - 1) ycor ] ]
end
to move-paddles-right
if [ pxcor] of one-of paddles != max-pxcor
[ask paddles [setxy (pxcor + 1) ycor ]]
end
to go
ask balls [ begin-bouncing ]
end
The buttons are setup,go,left and right and the monitors are score and lives. I need it to reset and subtract a life when the ball doesn't fall the on paddle, I need it to bounce a little more realistically and I need it to add a row when an entire board is clear until there are ten rows (when this happens it should say "WINNER" or something along those lines). Also a huge problem is that when the paddle goes too far left or right the whole thing stops and has an error.