Breakout NEED HELP!


mots

Member
Joined
Oct 24, 2005
Messages
257
So, brauche Hilfe bei meinen ersten Gehversuchen in Fenix. Ich will einen Breakout-Clone proggen, kann aber einige Sachen nicht: Blöcke oben spawnen und auf Berührung mit Ball verschwinden lassen; wenn life kleiner 0 ist, alles weg außer einer "GAME OVER"-Schrift; Grafik für Pad laden(ist in test.map)

Wäre nett, wenn sich mir jemand meinen Code 'mal anschauen würde und mir erklären könnte, wie diese Punkte gehen.

So, hier ist mein Quelltext:
Code:
<i>
</i>program BREAKOUT;

global
score[1];
life;

//Graphics:
gr_ball;
gr_bat;
gr_block;


//GP Keys
__A = _control;
__B = _alt;
__SELECT = _space;
__START = _enter;
__R = _tab;
__L = _backspace;

begin
//initialize screen:
set_title("Breakout by B4C|</");
full_screen = false;
set_mode(m320x240);

//Create graphics
gr_ball = new_map(5,5,8);
map_clear(0,gr_ball,300);

gr_bat = NEW_MAP(30,5,8);
map_clear(0,gr_bat,50);

gr_block = NEW_MAP(15,8,8);
map_clear(0,gr_block,25);

//Create a ball process
ball();

//Create a bat process
bat(20,_left,_right);

//Create some blocks
block(160,120);


//Write the current score on screen
write(0,80,20,4,"Score:");
write_int(0,110,20,4,&score[1]);
write (0,150,20,4,"Lifes:");
WRITE_INT (0,180,20,4, &life);


loop
  //If key start is pressed quit the game
  if(key(_esc))
    exit("",0);
  end

  frame;
end

end

/*
Process of a typical ball in a Pong game. Despite being square it bounces off bats
and the screen edge, and detects when a point has been made and when it it bounced back
off a bat.
*/
Process ball();

private
//Speed of the ball
speedo;

//Holds the bat's process identification number in case it collides with one
bat_id;

begin

//Initialize start values for most variables
//*position
x = 160;
y = 200;
life = 3;
//*angle
angle = rand(0,360) * 1000;
//*ball speed
speedo = 500;
//*graphic of the process
graph = gr_ball;



loop
  //Makes it bounce off the top and bottom of the screen(0 and 240, but giving
  //the ball a 5 pixel radius)
  if(x>319 or x<1)
    //Incoming angle is outgoing angle!
    angle = -angle + 180000;
  end
  if(y<5)
  angle=-angle;
  end

  //if off the screen on the left(point for player with score[0]
  if(y>320)
    //Add one to the score
    life--;
    //Reset speed to standard
    speedo = 500;
    //reset Position
    y = 120;
    x = 220;
  end


  //If it hits a bat
  if(bat_id = collision(type bat))
    angle = -angle;
    advance(3);
  end

  //Slowly increase the speed
  speedo+=3;
  //Move the ball in it's current direction
  advance(speedo/100);

  frame;
end

end

/*
A typical bat in a Pong game. It can move up and down with the keys
specified in the keyup and keydown parameters. x specifies the horizontal position on
screen.

*/
Process bat(x,keyup,keydown,);

begin

//Start in the middle of the screen
y = 235;
x = 160;



//use the graphic made for the bat
graph = gr_bat;

loop
  //Move the bat vertically if buttons are pressed
  if(key(keyup))
    x -= 12;
  end
  
  if(key(keydown))
    x += 12;
  end

  //Limit the bat movement on the edges of the screen
  if(x < 0)
    x=10;
  end
  
  if(x > 320)
    x=310;
  end
  
  frame;
end

end

process block(x,y);
private
ball_id;
begin 
  if (ball_id = collision(type ball))
  score+=100;
  end
end
  
process life();
begin
if(life<0)
let_me_alone();
Write(0,160,120,4,"GAME OVER");
end
  
end
 
1 Std. und 20 Minuten an einem Freitag abend vorbei und Du musst schon einen Dev-Beitrag pushen, weil niemand antwortet?

Schraub mal Deine Erwartungshaltung und Deinen Sarkasmus zurück.
 
sbx said:
1 Std. und 20 Minuten an einem Freitag abend vorbei und Du musst schon einen Dev-Beitrag pushen, weil niemand antwortet?

Schraub mal Deine Erwartungshaltung und Deinen Sarkasmus zurück.
jaja, war nur genervt, weil ich überhaupt nichts brauchbares im Netz gefunden hab.
 
Back
Top