initial add
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
jsmem.txt
|
||||
.DS_Store
|
1
.prosperon/project.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":"0.3.0","revision":"94bbc2b79c","title":"Flappy Bird"}
|
1
.prosperon/ur.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"_list":["watcher","gui","endgui","getready","scorewall","bird","pipe","startgui","background","ground","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur","prosperon/ur"],"watcher":{"name":"watcher","text":"watcher.jso"},"gui":{"name":"gui","text":"gui.jso"},"endgui":{"name":"endgui","text":"endgui.jso"},"getready":{"name":"getready","text":"getready.jso","data":"getready.json"},"scorewall":{"name":"scorewall","text":"scorewall.jso","data":"scorewall.json"},"bird":{"name":"bird","text":"bird/bird.jso","data":"bird/bird.json"},"pipe":{"name":"pipe","text":"pipe.jso","data":"pipe.json"},"startgui":{"name":"startgui","text":"startgui.jso"},"background":{"name":"background","data":"background/background.json"},"ground":{"name":"ground","data":"ground.json"},"prosperon/ur":{"name":"prosperon/ur","data":"audio/.prosperon/ur.json"}}
|
1
audio/.prosperon/ur.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"_list":["watcher","gui","bird","scorewall","pipe","startgui","ground","background"],"watcher":{"name":"watcher","text":"watcher.jso"},"gui":{"name":"gui","text":"gui.jso"},"bird":{"name":"bird","text":"bird.jso","data":"bird.json"},"scorewall":{"name":"scorewall","text":"scorewall.jso","data":"scorewall.json"},"pipe":{"name":"pipe","text":"pipe.jso","data":"pipe.json"},"startgui":{"name":"startgui","text":"startgui.jso"},"ground":{"name":"ground","data":"ground.json"},"background":{"name":"background","data":"background.json"}}
|
BIN
audio/die.qoa
Normal file
BIN
audio/point.qoa
Normal file
BIN
audio/swoosh.qoa
Normal file
25
background/background.json
Normal file
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"draw_layer":-10,
|
||||
"sprite": {
|
||||
"path": "day.png",
|
||||
"enabled": true,
|
||||
"color": [
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
],
|
||||
"pos": [
|
||||
0,
|
||||
0
|
||||
],
|
||||
"parallax": 10000000000000000,
|
||||
"angle": 0,
|
||||
"scale": [
|
||||
1,
|
||||
1
|
||||
],
|
||||
"drawmode": 0,
|
||||
"comp": "sprite"
|
||||
}
|
||||
}
|
BIN
background/day.png
Normal file
After Width: | Height: | Size: 6.9 KiB |
30
bird/bird.jso
Normal file
|
@ -0,0 +1,30 @@
|
|||
this.draw_layer = 5;
|
||||
var sp = this.add_component(component.sprite);
|
||||
sp.path = "yellowbird-midflap.png";
|
||||
|
||||
this.physupdate = function() {
|
||||
Game.camera.pos = [this.pos.x,0];
|
||||
this.angle = this.velocity.y / 6000;
|
||||
};
|
||||
|
||||
var flap = true;
|
||||
|
||||
this.inputs = {};
|
||||
this.inputs.space = function()
|
||||
{
|
||||
this.velocity = [this.velocity.x,0];
|
||||
this.pulse([0,400]);
|
||||
this.cry("wing.qoa");
|
||||
}
|
||||
|
||||
this.collide = function(hit)
|
||||
{
|
||||
if (hit.obj.ur === 'pipe' || hit.obj.ur === 'ground') {
|
||||
flap = false;
|
||||
this.circle2d.enabled = false;
|
||||
this.velocity = [0,0];
|
||||
player[0].uncontrol(this);
|
||||
game.gameover();
|
||||
this.cry("hit.qoa");
|
||||
}
|
||||
}
|
21
bird/bird.json
Normal file
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"sprite": {
|
||||
"pos": [
|
||||
-15.758410453796387,
|
||||
-11.1652193069458
|
||||
]
|
||||
},
|
||||
"circle2d": {
|
||||
"radius": 10.497515678405762,
|
||||
"offset": [
|
||||
0,
|
||||
0
|
||||
],
|
||||
"pos": [
|
||||
0,
|
||||
0
|
||||
],
|
||||
"sensor": true,
|
||||
"comp": "circle2d"
|
||||
}
|
||||
}
|
BIN
bird/hit.qoa
Normal file
BIN
bird/wing.qoa
Normal file
BIN
bird/yellowbird-downflap.png
Normal file
After Width: | Height: | Size: 426 B |
BIN
bird/yellowbird-midflap.png
Normal file
After Width: | Height: | Size: 425 B |
BIN
bird/yellowbird-upflap.png
Normal file
After Width: | Height: | Size: 427 B |
0
editorconfig.js
Normal file
14
endgui.jso
Normal file
|
@ -0,0 +1,14 @@
|
|||
this.gui = function()
|
||||
{
|
||||
GUI.image("gameover.png", [50,400]);
|
||||
GUI.text(`HIGH\n${game.save.high}`,[50,200],2);
|
||||
GUI.text(`SCORE\n${game.score}`, [50,300],2);
|
||||
GUI.text("Tap to restart", [50,100],2);
|
||||
}
|
||||
|
||||
this.inputs = {};
|
||||
this.inputs.space = function()
|
||||
{
|
||||
game.inputs.space();
|
||||
this.kill();
|
||||
}
|
60
game.js
Normal file
|
@ -0,0 +1,60 @@
|
|||
physics.gravity.strength = 1500;
|
||||
physics.gravity.mask = [true];
|
||||
var bird = world.spawn(ur.bird);
|
||||
bird.pos = [0,0];
|
||||
|
||||
world.spawn(ur.watcher);
|
||||
world.spawn(ur.gui);
|
||||
|
||||
var game = {};
|
||||
var ready;
|
||||
|
||||
var savefile = json.decode(io.slurp("@save.json"));
|
||||
if (savefile) game.save = savefile;
|
||||
else
|
||||
game.save = {high:0};
|
||||
|
||||
game.prepare = function()
|
||||
{
|
||||
game.score = 0;
|
||||
game.time = 3;
|
||||
ready = world.spawn(ur.getready);
|
||||
ready.pos = [-ready.width()/2, -ready.height()/2];
|
||||
player[0].control(ready);
|
||||
bird.hide();
|
||||
bird.pos = [0,-50];
|
||||
bird.velocity = [0,0];
|
||||
bird.warp_layer = [false];
|
||||
}
|
||||
|
||||
game.start = function()
|
||||
{
|
||||
ready.kill();
|
||||
bird.warp_layer = [true];
|
||||
player[0].control(bird);
|
||||
bird.show();
|
||||
bird.inputs.space.call(bird);
|
||||
bird.pulse([100,0]);
|
||||
bird.circle2d.enabled = true;
|
||||
}
|
||||
|
||||
game.gameover = function()
|
||||
{
|
||||
if (game.score > game.save.high) {
|
||||
game.save.high = game.score;
|
||||
io.slurpwrite("@save.json", json.encode(game.save));
|
||||
}
|
||||
|
||||
player[0].control(world.spawn(ur.endgui));
|
||||
}
|
||||
|
||||
game.inputs = {};
|
||||
game.inputs.space = function()
|
||||
{
|
||||
game.prepare();
|
||||
player[0].uncontrol(game);
|
||||
}
|
||||
|
||||
game.prepare();
|
||||
|
||||
return {game};
|
BIN
gameover.png
Normal file
After Width: | Height: | Size: 758 B |
4
getready.jso
Normal file
|
@ -0,0 +1,4 @@
|
|||
this.inputs = {};
|
||||
this.inputs.space = function() {
|
||||
game.start();
|
||||
}
|
24
getready.json
Normal file
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"sprite": {
|
||||
"path": "sprites/message.png",
|
||||
"enabled": true,
|
||||
"color": [
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
],
|
||||
"pos": [
|
||||
0,
|
||||
0
|
||||
],
|
||||
"parallax": 1,
|
||||
"angle": 0,
|
||||
"scale": [
|
||||
1,
|
||||
1
|
||||
],
|
||||
"drawmode": 0,
|
||||
"comp": "sprite"
|
||||
}
|
||||
}
|
47
ground.json
Normal file
|
@ -0,0 +1,47 @@
|
|||
{
|
||||
"sprite": {
|
||||
"path": "sprites/base.png",
|
||||
"enabled": true,
|
||||
"color": [
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
],
|
||||
"pos": [
|
||||
0.060742173343896866,
|
||||
-112.4241943359375
|
||||
],
|
||||
"parallax": 1,
|
||||
"angle": 0,
|
||||
"scale": [
|
||||
1,
|
||||
1
|
||||
],
|
||||
"drawmode": 0,
|
||||
"comp": "sprite"
|
||||
},
|
||||
"polygon2d": {
|
||||
"sensor": false,
|
||||
"comp": "polygon2d",
|
||||
"points": [
|
||||
[
|
||||
0.30321869254112244,
|
||||
-113.23556247353554
|
||||
],
|
||||
[
|
||||
336.33537493646145,
|
||||
-113.38103123009205
|
||||
],
|
||||
[
|
||||
337.1160312592983,
|
||||
-2.3673436790704727
|
||||
],
|
||||
[
|
||||
0.19449995458126068,
|
||||
-1.3619375079870224
|
||||
]
|
||||
]
|
||||
},
|
||||
"phys": 2
|
||||
}
|
4
gui.jso
Normal file
|
@ -0,0 +1,4 @@
|
|||
this.gui = function()
|
||||
{
|
||||
GUI.text(String(game.score).padStart(4,"0"), [5,480], 2);
|
||||
}
|
4
pipe.jso
Normal file
|
@ -0,0 +1,4 @@
|
|||
var sp = this.add_component(component.sprite);
|
||||
sp.path = "sprites/pipe-green.png";
|
||||
this.draw_layer = -5;
|
||||
this.phys = physics.static;
|
30
pipe.json
Normal file
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
"sprite": {
|
||||
"pos": [
|
||||
-25.87109375,
|
||||
-318.421875
|
||||
]
|
||||
},
|
||||
"polygon2d": {
|
||||
"sensor": false,
|
||||
"comp": "polygon2d",
|
||||
"points": [
|
||||
[
|
||||
-25.774422641843557,
|
||||
1.4665858447551727
|
||||
],
|
||||
[
|
||||
25.03435332328081,
|
||||
1.2390615716576576
|
||||
],
|
||||
[
|
||||
24.164442773908377,
|
||||
-317.82766630128026
|
||||
],
|
||||
[
|
||||
-23.20776028558612,
|
||||
-318.1667796447873
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
6
scorewall.jso
Normal file
|
@ -0,0 +1,6 @@
|
|||
this.collide = function(hit)
|
||||
{
|
||||
if (hit.obj.ur !== 'bird') return;
|
||||
game.score++;
|
||||
this.cry("audio/point.qoa");
|
||||
}
|
18
scorewall.json
Normal file
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"phys": 2,
|
||||
"edge2d": {
|
||||
"thickness": 0,
|
||||
"sensor": true,
|
||||
"cpoints": [
|
||||
[
|
||||
-0.11655732989311218,
|
||||
-31.846646707504988
|
||||
],
|
||||
[
|
||||
-0.023980766534805298,
|
||||
37.22600182145834
|
||||
]
|
||||
],
|
||||
"comp": "edge2d"
|
||||
}
|
||||
}
|
BIN
sprites/base.png
Normal file
After Width: | Height: | Size: 470 B |
BIN
sprites/message.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
sprites/pipe-green.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
46
watcher.jso
Normal file
|
@ -0,0 +1,46 @@
|
|||
var pipe_pair = function(x)
|
||||
{
|
||||
var gap = 100;
|
||||
var y = Math.random_range(0,200) - gap;
|
||||
world.spawn(ur.pipe).pos = [x,y];
|
||||
var pipe2 = world.spawn(ur.pipe);
|
||||
pipe2.scale = [1,-1];
|
||||
pipe2.pos = [x,y+gap];
|
||||
var wall = world.spawn(ur.scorewall);
|
||||
wall.pos = [x+30,y+gap/2];
|
||||
wall.edge2d.sensor = true;
|
||||
}
|
||||
|
||||
var gndx = -1000;
|
||||
var bgx = -1000;
|
||||
var lastpipe = Game.camera.right() + 50;
|
||||
|
||||
this.start = function()
|
||||
{
|
||||
pipe_pair(lastpipe);
|
||||
var bg = world.spawn(ur.background);
|
||||
bg.pos = [bgx,-bg.height()/2];
|
||||
bgx += bg.width()-1;
|
||||
bg = world.spawn(ur.background);
|
||||
bg.pos = [bgx,-bg.height()/2];
|
||||
}
|
||||
|
||||
this.update = function()
|
||||
{
|
||||
while (gndx < Game.camera.right()) {
|
||||
var g = world.spawn(ur.ground);
|
||||
g.pos = [gndx,-200];
|
||||
gndx += g.width()-3;
|
||||
}
|
||||
|
||||
while (bgx < Game.camera.right()) {
|
||||
var bg = world.spawn(ur.background);
|
||||
bg.pos = [bgx, -bg.height()/2];
|
||||
bgx += bg.width()-1;
|
||||
}
|
||||
|
||||
if (Game.camera.pos.x > lastpipe-200) {
|
||||
lastpipe += 200;
|
||||
pipe_pair(lastpipe);
|
||||
}
|
||||
}
|