lkarch.org/tools/gopher-kart/js/stateChoice.js
Lucas Kent e39465ad2f Changes to be committed:
new file:   Files/flashplayer_32_sa.exe
	new file:   favicon.ico
	new file:   globe.gif
	new file:   imgs/download.png
	new file:   imgs/zuck.jpg
	new file:   index.html
	new file:   other.ico
	new file:   script.js
	new file:   site.webmanifest
	new file:   sitemap.html
	new file:   styles/backround.css
	new file:   styles/border.css
	new file:   styles/fonts/Titillium_Web/OFL.txt
	new file:   styles/fonts/Titillium_Web/TitilliumWeb-Black.ttf
	new file:   styles/fonts/Titillium_Web/TitilliumWeb-Bold.ttf
	new file:   styles/fonts/Titillium_Web/TitilliumWeb-BoldItalic.ttf
	new file:   styles/fonts/Titillium_Web/TitilliumWeb-ExtraLight.ttf
	new file:   styles/fonts/Titillium_Web/TitilliumWeb-ExtraLightItalic.ttf
	new file:   styles/fonts/Titillium_Web/TitilliumWeb-Italic.ttf
	new file:   styles/fonts/Titillium_Web/TitilliumWeb-Light.ttf
	new file:   styles/fonts/Titillium_Web/TitilliumWeb-LightItalic.ttf
	new file:   styles/fonts/Titillium_Web/TitilliumWeb-Regular.ttf
	new file:   styles/fonts/Titillium_Web/TitilliumWeb-SemiBold.ttf
	new file:   styles/fonts/Titillium_Web/TitilliumWeb-SemiBoldItalic.ttf
	new file:   styles/fonts/webfontkit-20221027-163353/generator_config.txt
	new file:   styles/fonts/webfontkit-20221027-163353/specimen_files/grid_12-825-55-15.css
	new file:   styles/fonts/webfontkit-20221027-163353/specimen_files/specimen_stylesheet.css
	new file:   styles/fonts/webfontkit-20221027-163353/stylesheet.css
	new file:   styles/fonts/webfontkit-20221027-163353/titilliumweb-extralight-demo.html
	new file:   styles/fonts/webfontkit-20221027-163353/titilliumweb-extralight-webfont.woff
	new file:   styles/fonts/webfontkit-20221027-163353/titilliumweb-extralight-webfont.woff2
	new file:   styles/fonts/webfontkit-20221027-165950/generator_config.txt
	new file:   styles/fonts/webfontkit-20221027-165950/specimen_files/grid_12-825-55-15.css
	new file:   styles/fonts/webfontkit-20221027-165950/specimen_files/specimen_stylesheet.css
	new file:   styles/fonts/webfontkit-20221027-165950/stylesheet.css
	new file:   styles/fonts/webfontkit-20221027-165950/titilliumweb-bold-demo.html
	new file:   styles/fonts/webfontkit-20221027-165950/titilliumweb-bold-webfont.woff
	new file:   styles/fonts/webfontkit-20221027-165950/titilliumweb-bold-webfont.woff2
	new file:   styles/style.css
	new file:   tools/2048/.gitignore
	new file:   tools/2048/.jshintrc
	new file:   tools/2048/CONTRIBUTING.md
	new file:   tools/2048/LICENSE.txt
	new file:   tools/2048/README.md
	new file:   tools/2048/Rakefile
	new file:   tools/2048/favicon.ico
	new file:   tools/2048/index.html
	new file:   tools/2048/js/animframe_polyfill.js
	new file:   tools/2048/js/application.js
	new file:   tools/2048/js/bind_polyfill.js
	new file:   tools/2048/js/classlist_polyfill.js
	new file:   tools/2048/js/game_manager.js
	new file:   tools/2048/js/grid.js
	new file:   tools/2048/js/html_actuator.js
	new file:   tools/2048/js/keyboard_input_manager.js
	new file:   tools/2048/js/local_storage_manager.js
	new file:   tools/2048/js/tile.js
    new file:   tools/2048/meta/apple-touch-icon.png
	new file:   tools/webretro/cores/neocd_libretro.js
	new file:   tools/webretro/cores/neocd_libretro.wasm
	new file:   tools/webretro/cores/nestopia_libretro.js
	new file:   tools/webretro/cores/nestopia_libretro.wasm
	new file:   tools/webretro/cores/o2em_libretro.js
	new file:   tools/webretro/cores/o2em_libretro.wasm
	new file:   tools/webretro/cores/opera_libretro.js
	new file:   tools/webretro/cores/opera_libretro.wasm
2022-11-02 08:40:01 -04:00

151 lines
5.4 KiB
JavaScript

var StateChoice = {
preload: function () {
//Music and Sounds
game.load.audio("select", "assets/music/BeepBox-Song3-compressed.m4a");
//Spritesheets for the 3 colored Gophers
//Later put into 1 spritesheet
game.load.spritesheet("racer", "assets/character-select-loops.png", 76, 72, 7);
game.load.image("background", "assets/bg-color.png");
game.load.image("city", "assets/city-re-colored.png");
game.load.image("sky", "assets/clouds-re-colored.png");
game.load.image("mtn", "assets/mountains-recolored.png");
game.load.image("select", "assets/character-select-bg.png");
//sample test button
game.load.spritesheet("confirmButton", "assets/buttons-sprite.png", 111, 24, 4);
game.load.spritesheet("neon", "assets/neon-sign.png", 120, 30, 13);
game.load.spritesheet("buttons", "assets/on-off-buttons.png", 59, 41, 2);
game.load.spritesheet("blueMarquee", "assets/blue-crawl.png", 50, 12, 45);
game.load.spritesheet("pinkMarquee", "assets/pink-crawl.png", 50, 12, 45);
game.load.spritesheet("purpleMarquee", "assets/purple-crawl.png", 50, 12, 45);
// game.load.spritesheet("neonCnfrm", "assets/neon-sign.png", )
},
create: function () {
this.camera.reset();
//MUSIC
this.selectSong = game.add.audio("select");
//Watched youtube video, need to check docs for .play params
this.selectSong.play('', 0, 1, true);
//BACKGROUND
this.background = game.add.tileSprite(0, 0, 600, 432, "background");
this.sky = game.add.tileSprite(0, 10, 600, 78, "sky");
this.mtn = game.add.tileSprite(0, 250, 600, 131, "mtn");
this.city = game.add.tileSprite(0, 290, 600, 90, "city");
this.select = game.add.tileSprite(0, 0, 600, 432, "select");
//MARQUEE
//Blue
this.blueMarquee = game.add.sprite(game.world.bounds.height - 282, game.world.centerY-16, "blueMarquee");
this.blueMarquee.anchor.set(0.5, 0.5);
this.blueMarquee.animations.add("blueCrawl", [],15, true);
this.blueMarquee.animations.play("blueCrawl");
//Pink
this.pinkMarquee = game.add.sprite(game.world.bounds.height - 132, game.world.centerY-16, "pinkMarquee");
this.pinkMarquee.anchor.set(0.5, 0.5);
this.pinkMarquee.animations.add("pinkCrawl", [],13, true);
this.pinkMarquee.animations.play("pinkCrawl");
//Purple
this.purpleMarquee = game.add.sprite(game.world.bounds.height + 18, game.world.centerY-16, "purpleMarquee");
this.purpleMarquee.anchor.set(0.5, 0.5);
this.purpleMarquee.animations.add("purpleCrawl", [],10, true);
this.purpleMarquee.animations.play("purpleCrawl");
//Choose Racer1
this.pickRacer1 = game.add.button(game.world.bounds.height - 282, game.world.centerY+105,
"buttons", this.racerStart.bind(this, "blue"), this);
this.pickRacer1.anchor.set(0.5, 0.5);
//Choose Racer2
this.pickRacer2 = game.add.button(game.world.bounds.height - 132, game.world.centerY+105,
"buttons", this.racerStart.bind(this, "pink"), this);
this.pickRacer2.anchor.set(0.5, 0.5);
//Choose Racer3
this.pickRacer3 = game.add.button(game.world.bounds.height + 18, game.world.centerY+105,
"buttons", this.racerStart.bind(this, "purple"), this);
this.pickRacer3.anchor.set(0.5, 0.5);
this.buttons = {
"blue": this.pickRacer1,
"pink": this.pickRacer2,
"purple": this.pickRacer3
};
//BLACK AND WHITE GOPHERS
//Blue
this.blue = game.add.sprite(game.world.bounds.height - 282, game.world.centerY+40, "racer");
this.blue.frame = 1;
this.blue.animations.add("blue", [1, 2],9, true);
this.blue.anchor.set(0.5, 0.5);
this.blue.animations.play("blue");
//Pink
this.PinkGopher = game.add.sprite(game.world.bounds.height - 132, game.world.centerY+40, "racer");
this.PinkGopher.frame = 3;
this.PinkGopher.animations.add("pink", [3, 4],9, true);
this.PinkGopher.anchor.set(0.5, 0.5);
this.PinkGopher.animations.play("pink");
//Purple
this.PurpleGopher = game.add.sprite(game.world.bounds.height + 18, game.world.centerY+40, "racer");
this.PurpleGopher.frame = 5;
this.PurpleGopher.animations.add("purple", [5, 6],9, true);
this.PurpleGopher.anchor.set(0.5, 0.5);
this.PurpleGopher.animations.play("purple");
//CONFIRMATION BUTTON
this.startConfirm = game.add.button(game.world.bounds.height - 132, game.world.height-46,
"neon", this.startGame, this, 12, 12, 12);
this.startConfirm.frame = 12;
this.startConfirm.anchor.set(0.5, 0.5);
this.startConfirm.animations.add("neon", [],5, true);
this.startConfirm.anchor.set(0.5, 0.5);
// this.startConfirm.animations.play("neon");
},
startGame: function () {
if(character === undefined){
this.sampleText = game.add.text(game.world.centerX, 30, "You must choose a gopher!");
this.sampleText.fill = "ffffff";
this.sampleText.fontSize = 32;
this.sampleText.anchor.set(0.5, 0.5);
// console.log("You must choose a gopher!");
} else {
this.selectSong.stop();
game.state.start("StateMain");
}
},
racerStart: function (racer){
console.log(racer);
for (var key in this.buttons) {
this.buttons[key].frame = 0;
}
this.buttons[racer].frame = 1;
character = racer;
this.startConfirm.animations.play("neon");
// character.animations.play("blue");
// console.log(character);
},
update: function () {
this.sky.tilePosition.x -= 0.1;
},
};