Skip to content

Instantly share code, notes, and snippets.

View photonstorm's full-sized avatar

Richard Davey photonstorm

View GitHub Profile
@photonstorm
photonstorm / state-swap.js
Created March 3, 2016 21:24
How to keep the same Phaser Sprite through a change in State
var PewPew = {
// Our global Sprite, shared between States
spaceship: null
};
PewPew.Preloader = function () {};
PewPew.Preloader.prototype = {
@photonstorm
photonstorm / phaser-multi-texture-example.js
Created September 23, 2016 17:05
Phaser 3 Multi Texture Example
var game = new Phaser.Game(800, 600, Phaser.WEBGL_MULTI, 'phaser-example', { preload: preload, create: create });
function preload() {
game.load.image('mushroom', 'assets/sprites/mushroom2.png');
game.load.image('clown', 'assets/sprites/clown.png');
game.load.image('beball', 'assets/sprites/beball1.png');
game.load.image('coke', 'assets/sprites/cokecan.png');
game.load.image('asuna', 'assets/sprites/asuna_by_vali233.png');
@photonstorm
photonstorm / compressed-textures.js
Last active April 15, 2018 13:00
Phaser Compressed Texture Support
// Phaser 3 has the new Loader method, texture:
load.texture('factory', {
etc1: 'assets/factory_etc1.pkm',
s3tc: 'assets/factory_dxt1.pvr',
pvrtc: 'assets/factory_pvrtc.pvr',
truecolor: 'assets/factory.png'
});
// You can also use load.image:
@photonstorm
photonstorm / game.js
Created May 10, 2017 00:44
Phaser Game Config Object
var conf = {
width: 800,
height: 600,
renderer: Phaser.AUTO,
parent: 'phaser-example',
transparent: false,
antialias: false,
state: this,
scaleMode: Phaser.ScaleManager.EXACT_FIT
};
@photonstorm
photonstorm / gameframeworkterms.txt
Last active March 19, 2021 23:42
A list of the terms that game frameworks use to describe a 'scene' or 'state', i.e. such as a composition of objects in a level
Cocos2D - Scenes (and nodes)
Godot Engine - Scenes (and nodes)
CryEngine - Level
Torque3D - World and Level
Starling - nothing that I could find! In their tutorial 'Game' extends 'Sprite' :)
Urho3D - Scene (and Objects)
Atomic Game Engine - Scene (and nodes)
Monkey Engine - AppStates (short for Application States)
Banshee Engine - Level
Superpowers - Scenes (State is used too, to define entities changing states, Actors = Sprites)
@photonstorm
photonstorm / chiptune2-iOS.js
Created November 8, 2017 03:13
iOS fixed version of chiptune2.js
// audio context
var ChiptuneAudioContext = window['AudioContext'] || window['webkitAudioContext'];
// config
var ChiptuneJsConfig = function (repeatCount, context)
{
this.repeatCount = repeatCount;
this.context = context;
}
@photonstorm
photonstorm / phaser3-example.html
Last active February 21, 2024 05:27
Phaser 3 Example
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/phaser@3.15.1/dist/phaser-arcade-physics.min.js"></script>
</head>
<body>
<script>
var config = {
type: Phaser.AUTO,
@photonstorm
photonstorm / PlatformerAttempt1.js
Last active October 26, 2018 12:32 — forked from RabbidLnk/PlatformerAttempt1
Platformer Problem
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Basic Platofrmer Idea</title>
<script src="//cdn.jsdelivr.net/npm/phaser@3.15.1/dist/phaser.js"></script>
<style type="text/css">
body {
margin: 0;
}
class PointerMonitor
{
constructor (scene, pointer, swipeThreshold = 100, swipeDuration = 500)
{
// The current Scene
this.scene = scene;
// The Pointer we're monitoring for swipes
this.pointer = pointer;
@photonstorm
photonstorm / carfollow.js
Created June 24, 2020 09:31
Car follow path + boost
var config = {
type: Phaser.AUTO,
width: 800,
height: 600,
backgroundColor: '#2d2d2d',
parent: 'phaser-example',
scene: {
preload: preload,
create: create,
update: update