-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 657ca70
Showing
40 changed files
with
2,746 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# polaris |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<title>Making your first Phaser 3 Game - Part 7</title> | ||
<script src="//cdn.jsdelivr.net/npm/[email protected]/dist/phaser.js"></script> | ||
<style type="text/css"> | ||
body { | ||
margin: 0; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
|
||
<script type="text/javascript"> | ||
|
||
var config = { | ||
type: Phaser.AUTO, | ||
width: 800, | ||
height: 600, | ||
physics: { | ||
default: 'arcade', | ||
arcade: { | ||
gravity: { y: 300 }, | ||
debug: false | ||
} | ||
}, | ||
scene: { | ||
preload: preload, | ||
create: create, | ||
update: update | ||
} | ||
}; | ||
|
||
var player; | ||
var platforms; | ||
var cursors; | ||
|
||
var game = new Phaser.Game(config); | ||
|
||
function preload () | ||
{ | ||
this.load.image('sky', 'assets/sky.png'); | ||
this.load.image('ground', 'assets/platform.png'); | ||
this.load.image('star', 'assets/star.png'); | ||
this.load.image('bomb', 'assets/bomb.png'); | ||
this.load.spritesheet('dude', 'assets/dude.png', { frameWidth: 32, frameHeight: 48 }); | ||
} | ||
|
||
function create () | ||
{ | ||
this.add.image(400, 300, 'sky'); | ||
|
||
platforms = this.physics.add.staticGroup(); | ||
|
||
platforms.create(400, 568, 'ground').setScale(2).refreshBody(); | ||
|
||
platforms.create(600, 400, 'ground'); | ||
platforms.create(50, 250, 'ground'); | ||
platforms.create(750, 220, 'ground'); | ||
|
||
player = this.physics.add.sprite(100, 450, 'dude'); | ||
|
||
player.setBounce(0.2); | ||
player.setCollideWorldBounds(true); | ||
|
||
this.anims.create({ | ||
key: 'left', | ||
frames: this.anims.generateFrameNumbers('dude', { start: 0, end: 3 }), | ||
frameRate: 10, | ||
repeat: -1 | ||
}); | ||
|
||
this.anims.create({ | ||
key: 'turn', | ||
frames: [ { key: 'dude', frame: 4 } ], | ||
frameRate: 20 | ||
}); | ||
|
||
this.anims.create({ | ||
key: 'right', | ||
frames: this.anims.generateFrameNumbers('dude', { start: 5, end: 8 }), | ||
frameRate: 10, | ||
repeat: -1 | ||
}); | ||
|
||
cursors = this.input.keyboard.createCursorKeys(); | ||
|
||
this.physics.add.collider(player, platforms); | ||
} | ||
|
||
function update () | ||
{ | ||
if (cursors.left.isDown) | ||
{ | ||
player.setVelocityX(-160); | ||
|
||
player.anims.play('left', true); | ||
} | ||
else if (cursors.right.isDown) | ||
{ | ||
player.setVelocityX(160); | ||
|
||
player.anims.play('right', true); | ||
} | ||
else | ||
{ | ||
player.setVelocityX(0); | ||
|
||
player.anims.play('turn'); | ||
} | ||
|
||
if (cursors.up.isDown && player.body.touching.down) | ||
{ | ||
player.setVelocityY(-330); | ||
} | ||
} | ||
|
||
</script> | ||
|
||
</body> | ||
</html> |
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
class Example extends Phaser.Scene { | ||
create() { | ||
const graphics = this.add.graphics(); | ||
const outer_graphics = this.add.graphics(); | ||
const color = 0xffff00; | ||
const thickness = 2; | ||
const alpha = 1; | ||
|
||
let xCursor, | ||
yCursor = 0; | ||
|
||
// Events | ||
|
||
let draw = false; | ||
|
||
this.input.on("pointerdown", (pointer) => { | ||
const black = 0xc0c0c0; | ||
|
||
xCursor = pointer.downX; | ||
yCursor = pointer.downY; | ||
|
||
outer_graphics.fillStyle(black); | ||
outer_graphics.fillCircle(pointer.downX, pointer.downY, 60); | ||
outer_graphics.setDepth(-1); | ||
|
||
const gray = 0x808080; | ||
graphics.fillStyle(gray); | ||
graphics.fillCircle(pointer.downX, pointer.downY, 30); | ||
|
||
graphics.setDepth(1); | ||
|
||
draw = true; | ||
}); | ||
|
||
this.input.on("pointerup", () => { | ||
outer_graphics.clear(); | ||
graphics.clear(); | ||
draw = false; | ||
}); | ||
|
||
this.input.on("pointermove", (pointer) => { | ||
if (draw) { | ||
const dx = pointer.x - xCursor; | ||
const dy = pointer.y - yCursor; | ||
const distance = Math.sqrt(dx * dx + dy * dy); | ||
|
||
if (distance + 30 > 50) { | ||
// Calculate the angle to the pointer | ||
const angle = Math.atan2(dy, dx); | ||
// Position the gray circle within the black circle's radius | ||
pointer.x = xCursor + (50 - 30) * Math.cos(angle); | ||
pointer.y = yCursor + (50 - 30) * Math.sin(angle); | ||
} | ||
|
||
graphics.setDepth(1); | ||
graphics.clear(); | ||
const gray = 0x808080; | ||
graphics.fillStyle(gray); | ||
graphics.fillCircle(pointer.x, pointer.y, 30); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
const config = { | ||
type: Phaser.AUTO, | ||
parent: "phaser-example", | ||
width: 800, | ||
height: 600, | ||
scene: Example, | ||
}; | ||
|
||
const game = new Phaser.Game(config); |
Oops, something went wrong.