Skip to content

Instantly share code, notes, and snippets.

@Blecki
Created April 23, 2012 23:58
Show Gist options
  • Save Blecki/2474711 to your computer and use it in GitHub Desktop.
Save Blecki/2474711 to your computer and use it in GitHub Desktop.
package
{
import flash.display.BitmapData;
import flash.geom.Rectangle;
import gum.controls.Button;
import gum.controls.CheckBox;
import gum.FlashPunk.UIEntity;
import net.flashpunk.graphics.Image;
import net.flashpunk.graphics.Spritemap;
import net.flashpunk.Sfx;
import net.flashpunk.World;
import net.flashpunk.FP;
import gum.FlashPunk.GraphicControl;
import net.flashpunk.graphics.Text;
/**
* ...
* @author AJC
*/
public class MainMenu extends World
{
public var mainMenu:UIEntity = new UIEntity(0, 0, 800, 600);
public var music:Sfx = new Sfx(Assets.SONG1);
public var muteBox:CheckBox = null;
public var muted:Boolean = false;
override public function update():void
{
muted = muteBox.checked;
if (muted) music.volume = 0;
else if (music.volume < 1) music.volume += FP.elapsed * 4;
super.update();
}
public function MainMenu(muted:Boolean)
{
this.muted = muted;
add(mainMenu);
music.loop(0);
var _this = this;
mainMenu.AddGuiItem(new GraphicControl(new Rectangle(0, 0, 800, 600),
new Image(Assets.LOGO)));
mainMenu.AddGuiItem(new Button(new Rectangle(20, 210, 180, 20),
{
background: BitmapFont.MakeTextImage("ROCKY", 0xFFFFFFFF, 180),
hoverBackground: BitmapFont.MakeTextImage("ROCKY", 0xFFFF0000, 180),
//border: false,
OnClick: function(button:Button):void { music.stop(); FP.world = new TinyWorld(1, _this.muted); }
}));
mainMenu.AddGuiItem(new Button(new Rectangle(20, 240, 180, 20),
{
background: BitmapFont.MakeTextImage("EARTHLIKE", 0xFFFFFFFF, 180),
hoverBackground: BitmapFont.MakeTextImage("EARTHLIKE", 0xFFFF0000, 180),
//border: false,
OnClick: function(button:Button):void { music.stop(); FP.world = new TinyWorld(0, _this.muted); }
}));
mainMenu.AddGuiItem(new Button(new Rectangle(20, 270, 180, 20),
{
background: BitmapFont.MakeTextImage("JOVIAN", 0xFFFFFFFF, 180),
hoverBackground: BitmapFont.MakeTextImage("JOVIAN", 0xFFFF0000, 180),
//border: false,
OnClick: function(button:Button):void { music.stop(); FP.world = new TinyWorld(2, _this.muted); }
}));
mainMenu.AddGuiItem(new GraphicControl(new Rectangle(20, 300, 260, 290),
new Image(BitmapFont.MakeTextImage(
" CONTROLS\\\n" +
"WASD\\ARROWS MOVE\n" +
"QE\\JK STRAFE\n" +
"SPACE ATTACH SHIP\n" +
" TO BLOCK OR\n" +
" STITCH BLOCKS\n" +
"C\\M LET GO\n" +
"Z\\B METEORS\n" +
"P PAUSE",
0xFFFFFFFF, 260))));
mainMenu.AddGuiItem(new GraphicControl(new Rectangle(300, 210, 700 - 300 - 20, 390),
new Image(BitmapFont.MakeTextImage(
"OH NO] METEORS ARE PUMMELLING OUR PLANET FACTORY]] WE NEED TO GET THESE PLANETS OUT OF HERE] BUILD A PLANET" +
" OF AT LEAST 9 UNITS AND WELL GO DELIVER IT[ BUT KEEP THEM RECTANGULAR OKAY^ AND OUR CUSTOMERS LIKE THEIR" +
" PLANETS TO BE ALL ONE KIND OF THING] AND WE ARENT GOING TO DELIVER OUR OWN SUN SO DONT EVEN TRY]]" +
"\n\n\n\n" +
" ARNE ANDROIDARTS[COM\n" +
" BLECKI JEMGINE[OMNISU[COM\n" +
" BURNZEZ\n" +
"\n" +
"MADE WITH FLASHPUNK BOX2D GUM",
0xFFFFFFFF, 380
))));
muteBox = new CheckBox(new Rectangle(20, 600 - 30, 200, 20),
{
background: BitmapFont.MakeTextImage("MUTE MUSIC", 0xFFFFFFFF, 1000)
});
mainMenu.AddGuiItem(muteBox);
muteBox.checked = muted;
}
override public function render():void
{
FP.buffer.fillRect(new Rectangle(0, 0, 800, 600), 0xFF000000);
super.render();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment