Splinter
Member
K, ive been trying a few things in fenix, specifically to create a breakout clone to get the feel for the language. No suprise to me but ive already ran into a problem. After managing to draw the paddle and sort that out im having trouble with the ball. The ball comes from the paddle and moves up the screen. I want it to 'bouce/reflect' and go back towards the paddle. But i dont know how it is done. Here is what ive done so far:
Thanks in advance
Code:
Program Drawpaddle;
Global
//GP Keys
__A = _control;
__B = _alt;
__SELECT = _space;
__START = _enter;
__R = _tab;
__L = _backspace;
begin
//initialize screen:
full_screen = false;
set_mode(m320x240);
//Load graphics
LOAD_FPG("breakout.fpg");
//proccesses
paddle(160,200);
ball(160,190);
end
process paddle(x,y)
Begin
graph = 1;
Loop
//Defines control of paddle
if(key(_left))x-=6;end
if(key(_right))x+=6;end
//Defines boundaries for paddle
if(x<22)x=22;end
if(x>298)x=298;end
Frame;
end
end
process ball(x,y)
begin
graph = 2;
loop
//makes the ball move
y-=5;
//detects ball collision
if(x<5)x=5;end
if(x>315)x=316;end
if(y<5)y+=5;end
FRAME;
end
end
Thanks in advance