Jump to content


Photo

One Script Breakout Game


  • Please log in to reply
5 replies to this topic

#1 ProgWare

ProgWare

    GMC Member

  • New Member
  • 150 posts

Posted 23 September 2009 - 06:03 PM


One Script Breakout Game
Version 1.0


Script Informations : One script breakout game with powerups + score + lives
Version : 1.0
GM Version : Created with game maker 6.1 but it works on GM7.1 and RC version of GM8
/*
ProgWare Breakout Script
For Game Maker 6.1
*/

//SCORE = 0 - SETUP
if (score = 0) {
   //room setup
   room_caption = 'Breakout Game';
   show_score = false;
   room_speed = 30;
   background_color = c_black;
   //high score array setup
   hs_num = 5;
   hs_hi = 0;
   for (i=0; i<hs_num; i+=1) {
	 hs[i,0] = '';
	 hs[i,1] = 0;
	 hs[i,2] = 0;
   }
   frommenu = true;
   newhs = "";
   //score/life setup
   hits = 70;
   lives = 1;
   //ball setup
   ballx = 330; bally = 430;
   xspeed = 5; yspeed = -5;
   xspeed1 = 3; xspeed2 = -3; xspeed3 = 5;
   cx = 0; cy = 0;
   //fireball and shield powerup
   fire = false; firecount = 0;
   shield = false; shieldcount = 0;
   //brick setup
   for (i=0; i<5; i+=1) { for (j=0; j<3; j+=1) { brick[i,j] = true; }}
   br1 = true; br2 = true; brlife = true;
   br1x = 320; br1y = 150;
   br2x = 320; br2y = 210;
   brlifex = 320; brlifey = 240;
   endcheck = 0;
   curx = 0; cury = 0;
   si_x = 10; si_y = 10;
   si_dir = 15; si_move = 0;
   space = false; si_enabled = false
   //paddle setup
   paddlex = 330; paddley = 450;
   pw = 30;
   //powerup setup
   powerup = false;
   pupx = 0; pupy = 1;
   puptype = 1; pupcheck = false;
   //control setup
   message = ""
   mouse = true;
   score = 1;
}

// SCORE = 1 - MENU
if score = 1 {
   //draw text
   //interval += 0.1
   font_color = c_white; font_size = 9; draw_set_halign(fa_left);
   draw_text_color(10,2,'ProgWare Presents: One Script Breakout Game',c_white,c_white,c_white,c_white,1);
   draw_text_color(10,467,'Left Click or Press the Enter Key to Begin',c_white,c_white,c_white,c_white,1);
   draw_text_color(10,482,'Right Click or Press Control to View Scores',c_white,c_white,c_white,c_white,1);
   //check for input
   if mouse_check_button(mb_left)
   or keyboard_check(vk_enter)
   { io_clear(); score = 2;}
   if mouse_check_button(mb_right)
   or keyboard_check(vk_control)
   { io_clear(); score = 4;}
}


// SCORE = 2 - GAME
if score = 2 {
   //ball movement
   ballx = ballx + xspeed;
   bally = bally + yspeed;
   //ball collision
   if (ballx < 10) { xspeed = -(xspeed); }
   if (bally < 10) { yspeed = -(yspeed); }
   if (ballx > 630) { xspeed = -(xspeed); }
   if (ballx > 650) or (ballx < -10) {
	  xspeed = 5;
	  yspeed = -5;
	  ballx = 330; bally = 280;
   }
   if (bally > 470) {
	  if shield {
		 bally = 10;
	  }
	  else {
		 lives -= 1;
		 ballx = 330; bally = 430;
		 xspeed = 5; yspeed = -5
		 paddlex = 330;
		 pw = 30;
		 pupy = 1;
		 firecount = 0;
		 shieldcount = 0;
	  }
   } 
   if ((bally > 440 ) && (ballx >= paddlex-pw) && (ballx <= paddlex+pw)) {
	  yspeed = -(yspeed);
	  xspeed = (random(1) + 2) * sign(ballx - paddlex) * (abs(ballx - paddlex) / 5);
   } 
   //UFO 1 movement/collision
   br1x = br1x + xspeed1
   br1y = 150 + sin(br1x/(xspeed1 * 4))*5
   if (br1x < 20 ) or (br1x > 620 ) { xspeed1 = -(xspeed1) }
   if ((bally >= br1y - 10) && (bally <= br1y + 10) && (ballx >= br1x-29) && (ballx <= br1x+29) && (br1 = true)) {
	  if not fire { yspeed = -(yspeed); }
	  hits += 1; br1 = false;
	  if si_enabled = true and space = false {
		space = true;
		si_x = ballx; si_y = br1y - 25;
	  }
   } 
   //UFO 2 movement/collision
   br2x = br2x + xspeed2
   br2y = 210 + sin(br2x/(xspeed2 * 4))*5
   if (br2x < 20 ) or (br2x > 620 ) { xspeed2 = -(xspeed2) }
   if ((bally >= br2y - 10) && (bally <= br2y + 10) && (ballx >= br2x-29) && (ballx <= br2x+29) && (br2 = true)) {
	  if not fire { yspeed = -(yspeed); }
	  hits += 1; br2 = false;
	  if si_enabled = true and space = false {
		space = true;
		si_x = ballx; si_y = br2y - 25;
	  }
   }
   //space invader movement/collision
   if space = true {
	 si_move += 1;
	 if si_move = 5 {
	   si_move = 0;
	   si_x = si_x + si_dir;
	   if (si_x >= 620 and si_dir = 15)
	   or (si_x <= 20 and si_dir = -15) {
		 si_dir = -(si_dir);
		 si_y += 30;
	   }
	   if si_y >= paddley { space = false; }
	 }
	 if ((bally >= si_y - 9) && (bally <= si_y + 9) && (ballx >= si_x - 9) && (ballx <= si_x + 9)) {
	   space = false; hits += 1;
	   if not fire { yspeed = -(yspeed); }
	 } 
   }
   
   //life brick collision
   if ((bally >= 235 ) && (bally <= 245 ) && (ballx >= brlifex-39) && (ballx <= brlifex+39) && (brlife = true)) {
	  lives += 1; hits += 1; brlife = false;
	  if not fire { yspeed = -(yspeed); }
   } 
   //normal brick collision
   cx = -1;
   if (ballx >= 156) && (ballx <= 229) { cx = 0; }
   if (ballx >= 281) && (ballx <= 359) { cx = 1; }
   if (ballx >= 406) && (ballx <= 484) { cx = 2; }
   cy = -1;
   if (bally >= 25) && (bally <= 35) { cy = 0; }
   if (bally >= 55) && (bally <= 65) { cy = 1; }
   if (bally >= 85) && (bally <= 95) { cy = 2; }
   if (bally >= 115) && (bally <= 125) { cy = 3; }
   if (bally >= 175) && (bally <= 185) { cy = 4; }
   if cx >= 0 and cy >= 0 {
	  if brick[cy,cx] = true {
		 hits += 1; brick[cy,cx] = false; pupcheck = true;
		 if not fire { yspeed = -(yspeed); }
	  }
   } 
   //Powerup Creation
   if pupcheck {
	  pupcheck = false;
	  if not powerup {
		 powerup = floor(random(2));
		 puptype = floor(random(7));
		 pupx = random(470) + 15;
	  }
   }
   //Powerup Movement and Use
   if powerup {
	  pupy = pupy * 1.05;
	  if pupy >= 450 {
		 powerup = false; pupy = 1;
		 if puptype = 6 { puptype = floor(random(6)); }
		 if (pupx < paddlex+pw) and (pupx > paddlex-pw) {
			if puptype = 0 and pw >= 5 { pw = pw - 5; }
			if puptype = 1 and pw <= 60 { pw = pw + 5; }
			if puptype = 2 { lives += 1; }
			if puptype = 3 { fire = true; firecount += 500; }
			if puptype = 4 { fire = true; firecount += 500; }
			if puptype = 5 { hits += 20 }
		 }
	  }
   }
   //Fireball Time
   if fire {
	  firecount -= 1;
	  if firecount <= 0 { fire = false; }
   }
   if shield {
	  shieldcount -= 1;
	  if shieldcount <= 0 { shield = false; }
   }
   //Paddle Movement
   if (keyboard_check(vk_left)) and not mouse { paddlex -= 9; }
   if (keyboard_check(vk_right)) and not mouse { paddlex  += 9; }
   if (keyboard_check(vk_space)) { mouse = not mouse; keyboard_clear(vk_space); }
   if mouse { paddlex = paddlex + ((mouse_x - paddlex)/5); }
   if mouse_check_button(mb_right) { mouse = not mouse; mouse_clear(mb_right); }
   //Pause
   if mouse_check_button(mb_left) or keyboard_check(vk_control) {
	  io_clear()
	  score = 3;
   }
   //End Game
   if (lives <= 0) {
	  frommenu = false;
	  score = 4;
   }
   //Board Cleared
   endcheck = 0;
   for (i=0; i<5; i+=1) {
	   for (j=0; j<3; j+=1) {
		   if brick[i,j] = true { endcheck = true; }
	   }
   }
   if (endcheck = false) and (br1 == false) and (br2 == false) and (brlife == false) {
	  for (i=0; i<5; i+=1) { for (j=0; j<3; j+=1) { brick[i,j] = true; } }
	  br1 = true; br2 = true; brlife = true;
	  room_speed = room_speed + 5;
   }
}

//SCORE = 1, 2, or 3 - Draw Paddle/Bricks
if score = 1 or score = 2 or score = 3 {
   //draw paddle
   pen_color = c_white; brush_color = c_blue;
   draw_rectangle_color(paddlex-(pw-10),paddley,paddlex+(pw-10),paddley+10,c_white,c_white,c_blue,c_blue,fals
e);
   pen_color = c_white; brush_color = c_black;
   draw_circle_color(paddlex+(pw-10),paddley+5,6,c_white,c_black,false);
   draw_circle_color(paddlex+(pw-10),paddley+5,6,c_white,c_white,true);
   draw_circle_color(paddlex-(pw-10),paddley+5,6,c_white,c_black,false);
   draw_circle_color(paddlex-(pw-10),paddley+5,6,c_white,c_white,true);
   //draw standard bricks
   for (i=0; i<5; i+=1) {
	   for (j=0; j<3; j+=1) {
		   if brick[i,j] = true {
			  curx = j * 125; cury = i * 30;
			  if cury >= 120 { cury = 150; }
			  pen_color = c_white;
			  brush_color = make_color(0,i*63,j*127);
			  draw_rectangle_color(165 + curx,25 + cury,225 + curx,35 + cury,make_color(0,i*63,j*127),make_color(0,i*63,j*127),make_color(0,i*63,j*127),make_color(0,i*63,j*127),false);
			  draw_rectangle_color(165 + curx,25 + cury,225 + curx,35 + cury,c_white,c_white,c_white,c_white,true);
		   }
	   } 
   }
}

//SCORE = 2 or 3 - Draw
if score = 2 or score = 3 {
   //draw score/caption
   font_align = fa_left; font_color = c_white; font_size = 9;
   if score = 2 {
	  if mouse = true { message = 'Mouse (space bar or right click to change) / Click or Ctrl Key to Pause'; } 
	  else { message = 'Arrow Keys (space bar or right click to change) / Click or Ctrl Key to Pause'; }
   }
   else { message = 'PAUSED / Click or Ctrl Key to Continue'; }
   draw_text_color(10,467,'Hits: ' +string(hits) +' / Lives: ' +string(lives) +' / Level:' +string((room_speed-25)/5),c_white,c_white,c_white,c_white,1);
   draw_text_color(10,482,'Mode: ' +string(message),c_white,c_white,c_white,c_white,1);
   font_align = fa_right; font_color = c_yellow;
   if fire { draw_text_color(630,467,'Fire: ' +string(firecount div 10),c_yellow,c_yellow,c_yellow,c_yellow,1); }
   font_color = c_aqua;
   if shield { draw_text_color(630,482,'Save: ' +string(shieldcount div 10),c_aqua,c_aqua,c_aqua,c_aqua,1); }
   //draw ball
   if fire { pen_color = make_color(255,255,0); brush_color = make_color(255,0,0); }
   else { pen_color = c_white; brush_color = c_white; }
   brush_style = 1;
   draw_circle_color(ballx,bally,5,make_color(255,255,0),make_color(255,255,0),true);
   if shield { pen_color = c_aqua; brush_style = bs_hollow; }
   draw_circle_color(ballx,bally,(shieldcount/25)+5,c_aqua,c_aqua,true);
   brush_style = 1;
   //draw powerup
   if (powerup == true) {
	  if puptype = 0 {
		 pen_color = c_red;
		 brush_color = c_red;
		 draw_triangle_color(pupx-1,pupy,pupx-5,pupy+4,pupx-5,pupy-4,c_red,c_red,c_red,false);
		 draw_triangle_color(pupx+1,pupy,pupx+5,pupy+4,pupx+5,pupy-4,c_red,c_red,c_red,false);
	  }
	  if puptype = 1 {
		 pen_color = c_lime;
		 brush_color = c_lime;
		 draw_triangle_color(pupx-5,pupy,pupx-1,pupy+4,pupx-1,pupy-4,c_lime,c_lime,c_lime,false);
		 draw_triangle_color(pupx+5,pupy,pupx+1,pupy+4,pupx+1,pupy-4,c_lime,c_lime,c_lime,false);
	  }
	  if puptype = 2 {
		 pen_color = c_red;
		 brush_color = c_red;
		 draw_rectangle_color(pupx-1,pupy-5,pupx+1,pupy+5,c_red,c_red,c_red,c_red,false);
		 draw_rectangle_color(pupx-5,pupy-1,pupx+5,pupy+1,c_red,c_red,c_red,c_red,false);
	  }
	  if puptype = 3 {
		 pen_color = c_yellow;
		 brush_color = c_red;
		 draw_circle_color(pupx,pupy,5,c_yellow,c_red,false);
	  }
	  if puptype = 4 {
		 pen_color = c_aqua;
		 brush_color = c_navy;
		 draw_circle_color(pupx,pupy,5,c_aqua,c_navy,false);
	  }
	  if puptype = 5 {
		 font_color = c_lime;
		 draw_text_color(pupx-8,pupy-3,'20',c_lime,c_lime,c_lime,c_lime,1);
	  }
	  if puptype = 6 {
		 font_color = c_yellow;
		 draw_text_color(pupx-3,pupy-3,'?',c_yellow,c_yellow,c_yellow,c_yellow,1);
	  }
   }
   //draw life brick
   if (brlife == true) {
	  pen_color = c_white; brush_color = c_white;
	  draw_rectangle_color(brlifex-30,brlifey-5,brlifex+30,brlifey+5,c_white,c_white,c_white,c_w
hite,false);
	  pen_color = c_red; brush_color = c_red;
	  draw_rectangle_color(brlifex-1,brlifey-3,brlifex+1,brlifey+3,c_red,c_red,c_red,c_red,fals
e);
	  draw_rectangle_color(brlifex-3,brlifey-1,brlifex+3,brlifey+1,c_red,c_red,c_red,c_red,fals
e);
   }
   //draw UFOs
   if (br1 == true) {
	  pen_color = c_white; brush_color = c_gray;
	  draw_ellipse_color(br1x-20,br1y-5,br1x+20,br1y+5,c_white,c_gray,false);
	  pen_color = c_yellow; brush_color = c_yellow;
	  draw_ellipse_color(br1x-3,br1y-2,br1x+3,br1y+2,c_yellow,c_yellow,false);
	  draw_ellipse_color(br1x-11,br1y-2,br1x-8,br1y+2,c_yellow,c_yellow,false);
	  draw_ellipse_color(br1x+11,br1y-2,br1x+8,br1y+2,c_yellow,c_yellow,false);
	  draw_circle_color(br1x,br1y,2,c_yellow,c_yellow,false);
	  draw_circle_color(br1x-8,br1y,2,c_yellow,c_yellow,false);
	  draw_circle_color(br1x+8,br1y,2,c_yellow,c_yellow,false);
   }
   if (br2 == true) {
	  pen_color = c_white; brush_color = c_gray;
	  draw_ellipse_color(br2x-20,br2y-5,br2x+20,br2y+5,c_white,c_gray,false);
	  pen_color = c_yellow; brush_color = c_yellow;
	  draw_ellipse_color(br2x-3,br2y-2,br2x+3,br2y+2,c_yellow,c_yellow,false);
	  draw_ellipse_color(br2x-11,br2y-2,br2x-8,br2y+2,c_yellow,c_yellow,false);
	  draw_ellipse_color(br2x+11,br2y-2,br2x+8,br2y+2,c_yellow,c_yellow,false);
	  draw_circle_color(br2x,br2y,2,c_yellow,c_yellow,false);
	  draw_circle_color(br2x-8,br2y,2,c_yellow,c_yellow,false);
	  draw_circle_color(br2x+8,br2y,2,c_yellow,c_yellow,false);
   }
   //draw space invader
   if (space = true) {
	  pen_color = c_lime; brush_color = c_black;
	  draw_circle_color(si_x + 5, si_y + 4, 8,c_lime,c_black,false)
	  pen_color = c_lime; brush_color = c_lime; 
	  //horizontal lines
	  draw_line_color(si_x + 2,si_y,si_x + 8, si_y,c_lime,c_lime)
	  draw_line_color(si_x + 2,si_y + 1,si_x + 8, si_y + 1,c_lime,c_lime)
	  draw_line_color(si_x + 2,si_y + 4,si_x + 8, si_y + 4,c_lime,c_lime)
	  draw_line_color(si_x + 2,si_y + 5,si_x + 8, si_y + 5,c_lime,c_lime)
	  //vertical lines
	  draw_line_color(si_x,si_y + 2,si_x, si_y + 7,c_lime,c_lime)
	  draw_line_color(si_x + 1,si_y + 2,si_x + 1, si_y + 7,c_lime,c_lime)
	  draw_line_color(si_x + 4,si_y + 2,si_x + 4, si_y + 7,c_lime,c_lime)
	  draw_line_color(si_x + 5,si_y + 2,si_x + 5, si_y + 7,c_lime,c_lime)
	  draw_line_color(si_x + 8,si_y + 2,si_x + 8, si_y + 7,c_lime,c_lime)
	  draw_line_color(si_x + 9,si_y + 2,si_x + 9, si_y + 7,c_lime,c_lime)
   }
}

//SCORE = 3 - Paused Game
if score = 3 {
   //draw store options
   pen_color = c_white; brush_color = c_black;
   draw_rectangle_color(10,260,630,400,c_white,c_white,c_black,c_black
,true)
   font_align = fa_left; font_color = c_white; font_size = 9;
   draw_text_color(20,270,'Key',c_white,c_white,c_white,c_white,1); draw_text_color(55,270,'Price',c_white,c_white,c_white,c_white,1); draw_text_color(125,270,'Item',c_white,c_white,c_white,c_white,1);
   draw_text_color(20,285,'Q',c_white,c_white,c_white,c_white,1);   draw_text_color(55,285,'100',c_white,c_white,c_white,c_white,1);   draw_text_color(125,285,'Extra Life',c_white,c_white,c_white,c_white,1);
   draw_text_color(20,300,'W',c_white,c_white,c_white,c_white,1);   draw_text_color(55,300,'75',c_white,c_white,c_white,c_white,1);	draw_text_color(125,300,'50+ Shield',c_white,c_white,c_white,c_white,1);
   draw_text_color(20,315,'E',c_white,c_white,c_white,c_white,1);   draw_text_color(55,315,'75',c_white,c_white,c_white,c_white,1);	draw_text_color(125,315,'50+ Fireball',c_white,c_white,c_white,c_white,1);
   if si_enabled = false {
	 draw_text_color(20,330,'R',c_white,c_white,c_white,c_white,1);   draw_text_color(55,330,'50',c_white,c_white,c_white,c_white,1);  draw_text_color(125,330,'Space Invader',c_white,c_white,c_white,c_white,1);
   }

   draw_text_color(20,360,'Z/C',c_white,c_white,c_white,c_white,1);   draw_text_color(55,360,'Free',c_white,c_white,c_white,c_white,1);  draw_text_color(125,360,'Change \# of HS Slots - Currently ' +string(hs_num),c_white,c_white,c_white,c_white,1);
   //check input for store
   if keyboard_key = ord('Q') {
	   io_clear();
	   if hits >= 100 {
		 hits -= 100;
		 lives += 1;
	   }
   }
   if keyboard_key = ord('W') {
	   io_clear();
	   if hits >= 75 {
		 hits -= 75;
		 shield = true;
		 shieldcount += 500;
	   }
   }
   if keyboard_key = ord('E') {
	   io_clear();
	   if hits >= 75 {
		 hits -= 75;
		 fire = true;
		 firecount += 500;
	   }
   }
   if keyboard_key = ord('R') {
	   io_clear();
	   if hits >= 50 {
		 hits -= 50;
		 si_enabled = true;
	   }
   }

   if keyboard_key = ord('C') and hs_num < 10 {
	   io_clear();
	   hs_num += 1;
   }
   if keyboard_key = ord('Z') and hs_num > 3 {
	   io_clear();
	   hs_num -= 1;
   }
   //check input
   if mouse_check_button(mb_left) or keyboard_check(vk_control) {
	  io_clear();
	  score = 2;
   }
}

//SCORE = 4 - Highscore Load from File
if score = 4 {
   //Read from file
   if file_exists('breakout.txt') {
	  file_open_read('breakout.txt');
	  file_readln();
	  for (i=0; i<hs_num; i+=1) {
		  if not file_eof() {
			 hs[i,0] = file_read_string(); file_readln();
			 hs[i,1] = file_read_real(); file_readln();
			 hs[i,2] = file_read_real(); file_readln();
		  }
		  else {
			 hs[i,0] = "<no one>";
			 hs[i,1] = 0;
			 hs[i,2] = 0;
		  }
	  }
	  file_close();
   }
   //clear keyboard input
   keyboard_string = '';
   //check where to go next
   if frommenu { score = 7; }
   if hits > hs[2,1] { score = 5; }
   else { score = 7; }
}

//SCORE = 5 - Enter Name for Highscore
if score = 5 {
   //draw text
   font_align = fa_left; font_color = c_white; font_size = 9;
   draw_text_color(10,2,'Enter Your Name - Press Enter or Left Click to Continue',c_white,c_white,c_white,c_white,1);
   draw_text_color(10,482,keyboard_string + '_',c_white,c_white,c_white,c_white,1);
   //check for input
   if keyboard_lastchar = '#' { keyboard_key_press(vk_backspace); }
   if mouse_check_button(mb_left) or keyboard_check(vk_enter) {
	  keyboard_clear(vk_enter);
	  mouse_clear(mb_left);
	  score = 6;
   }
}

//SCORE = 6 - Replace highscores with new
if score = 6 {
   //switch spots depending on new score
   newhs = string(keyboard_string)
   for (i=0; i<hs_num; i+=1) {
	 if hits > hs[i,1] {
	   for (j=hs_num-1; j>i; j-=1) {
		 for (k=0; k<3; k+=1) {
			 hs[j,k] = hs[j-1,k];
		 }
	   }
	   hs[i,0] = newhs;
	   hs[i,1] = hits;
	   hs[i,2] = (room_speed-25)/5;
	   hits = 0;
	 }
   }
   //rewrite the file
   file_open_write('breakout.txt');
   file_write_real(hs_num); file_writeln();
   for (i=0; i<hs_num; i+=1) {
	   file_write_string(hs[i,0]); file_writeln();
	   file_write_real(hs[i,1]); file_writeln();
	   file_write_real(hs[i,2]); file_writeln();
   }
   file_close();
   score = 7;
}

//SCORE = 7 - Highscore List
if score = 7 {
   //draw texts
   font_align = fa_left; font_color = c_white; font_size = 9;
   draw_text_color(10,2,'High Scores - Press Enter or Left Click to Continue',c_white,c_white,c_white,c_white,1);
   draw_text_color(10,17,'Press Delete or Right Click to Clear Highscores',c_white,c_white,c_white,c_white,1);
   for (i=0; i<hs_num; i+=1) {
	 hs_hi = 482 - 15*(i);
	 draw_text_color(10,hs_hi,'' + string(i+1),c_white,c_white,c_white,c_white,1);
	 draw_text_color(40,hs_hi,hs[i,2],c_white,c_white,c_white,c_white,1);
	 draw_text_color(60,hs_hi,hs[i,1],c_white,c_white,c_white,c_white,1);
	 draw_text_color(150,hs_hi,hs[i,0],c_white,c_white,c_white,c_white,1);
   }
   hs_hi = 482 - 15*(hs_num);
   draw_text_color(10,hs_hi,'Pl.',c_white,c_white,c_white,c_white,1);
   draw_text_color(40,hs_hi,'Lv',c_white,c_white,c_white,c_white,1);
   draw_text_color(60,hs_hi,'Score',c_white,c_white,c_white,c_white,1);
   draw_text_color(150,hs_hi,'Name:',c_white,c_white,c_white,c_white,1);
   //check for input
   if mouse_check_button(mb_left) or keyboard_check(vk_enter) {
	  io_clear();
	  score = 0;
   }
   if mouse_check_button(mb_right) or keyboard_check(vk_delete) {
	  io_clear();
	  score = 8;
   }
}

//SCORE = 8 - Clear Highscores
if score = 8 {
   //clear scores
   for (i=0; i<hs_num; i+=1) {
	  hs[i,0] = "<no one>";
	  hs[i,1] = 0;
	  hs[i,2] = 0;
   }
   //rewrite the file
   file_open_write('breakout.txt');
   file_write_real(hs_num); file_writeln();
   for (i=0; i<hs_num; i+=1) {
	   file_write_string(hs[i,0]); file_writeln();
	   file_write_real(hs[i,1]); file_writeln();
	   file_write_real(hs[i,2]); file_writeln();
   }
   file_close();
   score = 7;

Downloads :
Breakout.gm6 ~ Download
Breakout.gml ~ Download
  • 0

#2 weckar

weckar

    Helping Hand

  • GMC Member
  • 2616 posts
  • Version:Unknown

Posted 23 September 2009 - 09:42 PM

how does this extend game maker?
And shouldn't a real OSG go in the room creation code?
  • 0
Just had my 10-year forum anniversary. Feeling - Even - Older.
Awards & Recognitions:
Spoiler

[I have a nasty habit of writing "it is" simply as "it". Please forgive me, I try to avoid it.]

#3 BBGaming

BBGaming

    Programmer

  • GMC Member
  • 2478 posts
  • Version:GM7

Posted 24 September 2009 - 03:52 AM

And shouldn't a real OSG go in the room creation code?

Possibly, but that doesn't show any programming ingenuity. All that does is take all of GM's built in object structure and stuff it into one script instead of the IDE. Doing it like this is a great step into designing your own game loop, which is something a lot of GM users simply can't do (and have to do in other languages).

That said, this still isn't of much use. Maybe it's in the wrong section. Perhaps the open source forum?
  • 0

Posted Image
Game Widgets
- Your pure-GML solution to API DLLs. Featured in Markup Magazine!

My Portfolio - All my good games and resources
Moved away from the forum - e-mail me if you need quick contact (hi_146@hotmail.com).


#4 xot

xot

    GMC Dismember

  • GMC Elder
  • 4785 posts
  • Version:GM:Studio

Posted 24 September 2009 - 12:33 PM

I'm not sure that abandoning subroutines is something one should strive for, but as an exercise it's fun and an interesting challenging to work within self-imposed limits like this.

In any event, I'll move this to Open Source. It certainly doesn't belong in Extending. If the author has other ideas, please PM me.
  • 0
GMLscripts.com, rise from your grave!

If any of my posts contain broken images or links, I can probably supply them for you. PM with a link to the post.

#5 Krisando

Krisando

    GMC Member

  • New Member
  • 1351 posts

Posted 25 September 2009 - 10:24 AM

Uhh I swear theres <= GM5 coding in this.. Did you by any chance steal this code un aware of it being made originally for Gm5?

Also you should work on your code formatting. =/

Edited by Krisando, 25 September 2009 - 10:25 AM.

  • 0

Posted Image


#6 maarten

maarten

    GMC Member

  • New Member
  • 354 posts

Posted 25 September 2009 - 10:39 AM

rofl what makes you say that Krisando?
i always liked osg games! its fun to stuff everything in one script. but, unless your programming a game in a non OO programming language i doubt you have to write loops like these :)
  • 0
"There are 10 kinds of people; those who can count binary and those who can't"
in need of help? pm me / DO NOT pm me about your forum/offers