//Sample Solution
const gameState = {}
function preload() {
this.load.image('codey', 'https://s3.amazonaws.com/codecademy-content/courses/learn-phaser/codey.png');
}
function create() {
gameState.codey = this.add.sprite(150, 200, 'codey')
// Set cursor keys here!
gameState.cursors = this.input.keyboard.createCursorKeys();
}
function update() {
// Update based on keypress here!
if(gameState.cursors.right.isDown){
gameState.codey.x += 5
}
if(gameState.cursors.left.isDown){
gameState.codey.x -= 5
}
if(gameState.cursors.up.isDown){
gameState.codey.y -= 5
}
if(gameState.cursors.down.isDown){
gameState.codey.y += 5
}
}
const config = {
type: Phaser.AUTO,
width: 400,
height: 500,
backgroundColor: "#5f2a55",
scene: {
preload,
create,
update
}
}
const game = new Phaser.Game(config)
Quotes help make search much faster. Example: "Practice Makes Perfect"
Showing posts with label Learn Phaser. Show all posts
Showing posts with label Learn Phaser. Show all posts
Monday, September 9, 2019
Codecademy Learn Phaser: Basics Storing State 8/12
//Sample Solution
const gameState = {};
function create() {
gameState.circle = this.add.circle(40, 100, 20, 0xff9999)
}
function update() {
gameState.circle.y += 1
}
const config = {
type: Phaser.AUTO,
width: 450,
height: 600,
backgroundColor: "#99ff99",
scene: {
create,
update
}
}
const game = new Phaser.Game(config)
const gameState = {};
function create() {
gameState.circle = this.add.circle(40, 100, 20, 0xff9999)
}
function update() {
gameState.circle.y += 1
}
const config = {
type: Phaser.AUTO,
width: 450,
height: 600,
backgroundColor: "#99ff99",
scene: {
create,
update
}
}
const game = new Phaser.Game(config)
Codecademy Learn Phaser: Basics Move Your Bodies 7/12
//Sample Solution
let codey;
function preload() {
this.load.image('codey', 'https://s3.amazonaws.com/codecademy-content/courses/learn-phaser/codey.png');
}
function create() {
codey = this.add.sprite(30, 200, 'codey')
}
// Create your update() function here
function update() {
codey.x += 1;
}
const config = {
type: Phaser.AUTO,
width: 400,
height: 400,
backgroundColor: "#5f2a55",
scene: {
preload,
create,
// Include update here!
update
}
}
const game = new Phaser.Game(config)
let codey;
function preload() {
this.load.image('codey', 'https://s3.amazonaws.com/codecademy-content/courses/learn-phaser/codey.png');
}
function create() {
codey = this.add.sprite(30, 200, 'codey')
}
// Create your update() function here
function update() {
codey.x += 1;
}
const config = {
type: Phaser.AUTO,
width: 400,
height: 400,
backgroundColor: "#5f2a55",
scene: {
preload,
create,
// Include update here!
update
}
}
const game = new Phaser.Game(config)
Codecademy Learn Phaser: Basics Start Making A Scene 6/12
//Sample Solution
// Create a create() function here:
function create() {
this.add.text(100,170,"Spaze Invaydurs");
}
const config = {
type: Phaser.AUTO,
width: 450,
height: 600,
backgroundColor: "#a0a0dd",
// Add in the scene information in the config here:
scene: {
create
}
}
const game = new Phaser.Game(config)
// Create a create() function here:
function create() {
this.add.text(100,170,"Spaze Invaydurs");
}
const config = {
type: Phaser.AUTO,
width: 450,
height: 600,
backgroundColor: "#a0a0dd",
// Add in the scene information in the config here:
scene: {
create
}
}
const game = new Phaser.Game(config)
Codecademy Learn Phaser: Basics Create A Config 5/12
//Sample Solution
const config = {
width: 450,
height: 600,
backgroundColor: "#0000ff",
}
const game = new Phaser.Game(config)
const config = {
width: 450,
height: 600,
backgroundColor: "#0000ff",
}
const game = new Phaser.Game(config)
Codecademy Learn Phaser: Basics Draw A Background Image 4/12
//Sample Solution
function preload() {
// Load in the background image here!
this.load.image('sky','https://s3.amazonaws.com/codecademy-content/courses/learn-phaser/sky.jpg');
}
function create() {
// Put the background image in the scene here!
this.add.image(200,200,'sky');
}
const config = {
type: Phaser.AUTO,
width: 450,
height: 600,
backgroundColor: "#5f2a55",
scene: {
create,
preload
}
}
const game = new Phaser.Game(config)
function preload() {
// Load in the background image here!
this.load.image('sky','https://s3.amazonaws.com/codecademy-content/courses/learn-phaser/sky.jpg');
}
function create() {
// Put the background image in the scene here!
this.add.image(200,200,'sky');
}
const config = {
type: Phaser.AUTO,
width: 450,
height: 600,
backgroundColor: "#5f2a55",
scene: {
create,
preload
}
}
const game = new Phaser.Game(config)
Codecademy Learn Phaser: Basics Draw A Sprite 3/12
//Sample Solution
function preload() {
// Load in the sprite here!
this.load.image('codey','https://s3.amazonaws.com/codecademy-content/courses/learn-phaser/codey.png')
}
function create() {
// Create a sprite game object here!
this.add.sprite(40,50,'codey')
}
const config = {
type: Phaser.AUTO,
width: 450,
height: 600,
backgroundColor: "#5f2a55",
scene: {
create,
preload
}
}
const game = new Phaser.Game(config)
function preload() {
// Load in the sprite here!
this.load.image('codey','https://s3.amazonaws.com/codecademy-content/courses/learn-phaser/codey.png')
}
function create() {
// Create a sprite game object here!
this.add.sprite(40,50,'codey')
}
const config = {
type: Phaser.AUTO,
width: 450,
height: 600,
backgroundColor: "#5f2a55",
scene: {
create,
preload
}
}
const game = new Phaser.Game(config)
Codecademy Learn Phaser: Basics Draw A Circle 2/12
//Sample Solution
function create() {
let circle1 = this.add.circle(50, 100, 90, 0xFFF070);
let circle2 = this.add.circle(95, 300, 80, 0xFF0000);
let circle3 = this.add.circle(200, 200, 100, 0x9F00D0);
let circle4 = this.add.circle(300, 400, 10, 0x00E030);
// Add in a circle here!
let circle5 = this.add.circle(450, 600, 240, 0xFFFFFF);
}
const config = {
type: Phaser.AUTO,
width: 450,
height: 600,
scene: {
create
}
}
const game = new Phaser.Game(config)
function create() {
let circle1 = this.add.circle(50, 100, 90, 0xFFF070);
let circle2 = this.add.circle(95, 300, 80, 0xFF0000);
let circle3 = this.add.circle(200, 200, 100, 0x9F00D0);
let circle4 = this.add.circle(300, 400, 10, 0x00E030);
// Add in a circle here!
let circle5 = this.add.circle(450, 600, 240, 0xFFFFFF);
}
const config = {
type: Phaser.AUTO,
width: 450,
height: 600,
scene: {
create
}
}
const game = new Phaser.Game(config)
Codecademy Learn Phaser: Basics Hello World 1/12
//Sample Solution
function create() {
// Change "Codey's Adventures\n in Code World" to the name of your game
this.add.text(50, 100, "Nathan's Nation", { font: "40px Times New Roman", fill: "#ffa0d0"});
// Change "by Codecademy" to your name!
this.add.text(130, 300, "by nathan", { font: "20px Times New Roman", fill: "#ffa0d0"});
}
const config = {
type: Phaser.AUTO,
width: 450,
height: 600,
backgroundColor: "#5f2a55",
scene: {
create
}
};
const game = new Phaser.Game(config);
function create() {
// Change "Codey's Adventures\n in Code World" to the name of your game
this.add.text(50, 100, "Nathan's Nation", { font: "40px Times New Roman", fill: "#ffa0d0"});
// Change "by Codecademy" to your name!
this.add.text(130, 300, "by nathan", { font: "20px Times New Roman", fill: "#ffa0d0"});
}
const config = {
type: Phaser.AUTO,
width: 450,
height: 600,
backgroundColor: "#5f2a55",
scene: {
create
}
};
const game = new Phaser.Game(config);
Subscribe to:
Posts (Atom)
This is an example of scrolling text using Javascript.
Popular Posts
-
//Sample Solution const gameState = {} function preload() { this.load.image('codey', 'https://s3.amazonaws.com/codecademy-...
-
//sample solution function guessNumber(number, clue) { // Prompt the user for a number using the string value of clue guess = promp...
-
//sample solution //Here is the original card object var card1 = {"suit":"clubs", "rank": 8}; //Create a...
-
#sample solution def colorful_conditions(): color = "blue" if color == "red": return "firs...
-
function checkAnswerWrongPlace(ans, realanswer){ // This method compares two input strings representing a player's guess ("an...
-
Instruction: Find the id of the flights whose distance is below average for their carrier. Sample Solution: SELECT id FROM flights AS f...
-
# note: The instructions state to use "text.txt" but an error comes up stating that the file does not exist # as a work around, ...
-
# Sample Solution # Import packages import numpy as np import pandas as pd # Read in transactions data transactions = pd.read_csv(...
-
# Sample Solution from song_data import songs import numpy as np q1 = np.quantile(songs, 0.25) #Create the variables q3 and interquarti...
-
/*sample solution for style.css*/ body > p { background: green; } p { background: yellow; }