Language Game Maker Language
(GMLv6, requires no extra coding to enabl)
Date: | 05/04/07 |
Author: | Scoochi2 |
URL: | http://scoochi2.freehostia.com |
Comments: | 2 |
Info: | http://www.yoyogames.com/gamemaker/ |
Score: | ![]() |
/* 99 beer bottles by Scoochi2 start a new game, add a room, and put this entire code in the room creation event ...or add it as a script/code in an existing game. Run the script to go to bottles. */ /* ~~~~~~~~~~~~~~~ object startup ~~~~~~~~~~~~~~~ */ global.playbottles=object_add(); // add an object global.scroller=0; // we need to see all verses... global.scrollchange=1; // multiplier for 'rotation' global.count=99; // how many bottles to start with? global.text=''; // our 'poem' holder :) object_event_add (global.playbottles,ev_create,'',' while global.count >= 1 { global.text+=string(global.count)+" bottle"; if global.count != 1 then global.text+="s"; global.text+=" of beer on the wall, "+string(global.count)+" bottle"; if global.count != 1 then global.text+="s"; global.text+=" of beer.#Take one down and pass it around, "; global.count-=1; if global.count != 0 then{ global.text+=string(global.count)+" bottle"; if global.count != 1 then global.text+="s"; global.text+=" of beer on the wall."; } else global.text+="no more bottles of beer on the wall."; global.text+="##"; } global.text+="No more bottles of beer on the wall, no more bottles of beer.#Go to the store and buy some more, 99 bottles of beer on the wall."; '); object_event_add (global.playbottles,ev_keyboard,vk_add,"global.scrollchange+=1"); object_event_add (global.playbottles,ev_keyboard,vk_subtract,"global.scrollchange-=1"); object_event_add (global.playbottles,ev_keypress,vk_home,"global.scroller=0"); object_event_add (global.playbottles,ev_keypress,vk_escape,"game_end();"); object_event_add (global.playbottles,ev_draw,'',' draw_text(10,10-global.scroller,global.text); '); object_event_add (global.playbottles,ev_step,ev_step_normal,"global.scroller+=global.scrollchange"); /* ~~~~~~~~~~~~~~~ game settings ~~~~~~~~~~~~~~~ */ window_set_cursor(cr_none); global.bottlesgo=room_add(); room_set_width(global.bottlesgo,700); room_set_height(global.bottlesgo,480); room_set_background_color(global.bottlesgo,c_white,1); room_set_caption(global.bottlesgo,"Press Esc to quit, plus key to increase speed, subtract key to decrease speed and the home key to restart"); /* ~~~~~~~~~~~~~~~ change room and create instance ~~~~~~~~~~~~~~~ */ room_set_code(global.bottlesgo,"instance_create(0,0,global.playbottles);"); room_goto(global.bottlesgo);
Download Source | Write Comment
Alternative Versions
Version | Author | Date | Comments | Rate |
---|---|---|---|---|
1 | Jake Gilbert | 05/25/05 | 8 | ![]() ![]() |
1 var, no loops/recursion, EOB adaptable | brac37 | 10/24/09 | 0 | ![]() ![]() |
Download Source | Write Comment
Add Comment
Please provide a value for the fields Name,
Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.
Please don't post large portions of code here! Use the form to submit new examples or updates instead!
Comments
The code could be stripped down to:
<code>
for (i=99; i>0; i-=1) {
show_message(string_replace(string(i),"0","no"
Take one down and pass it around, "+string(i-1)+" bottle"+string_repeat("s",i == 0)+" of beer on the wall."
}
show_message("No more bottles of beer on the wall, no more bottles of beer.
Go to the store and buy some more, 99 bottles of beer on the wall."
</code>
The show_message could be arbitrarily replaced with a string too.