Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladimir Zatoloka committed Mar 26, 2018
0 parents commit 67aadb7
Show file tree
Hide file tree
Showing 9 changed files with 1,065 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#############
## Windows detritus
#############

# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Mac crap
.DS_Store


config/
*.db
*.log
54 changes: 54 additions & 0 deletions app.psgi
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env perl

use strict;
use warnings;

use lib 'lib';
use feature 'say';

use IO::All;
# use Template;

# TODO: move to the tools pm?
use constant DEBUG => $ENV{DEBUG} // $ENV{PLACK_ENV} // '' eq 'development';

use if DEBUG, 'Data::Dumper';

my %static_files = (
'/' => {fn => 'index.html', headers => ['Content-Type' => 'text/html; charset=utf-8']},
'/bunny.png' => 0,
'/circle.png' => 0,
'/js/Character.js' => 0,
'/js/Construction.js' => 0,
'/js/Particle.js' => 0,
);
my %html = (
# 'index._.html' => 'index.html',
);

if (DEBUG) {
# my $tt = Template->new({});
while (my ($from, $to) = each %html) {
# $tt->process($from, undef, $to);
my $text = io($from)->slurp();
$text =~ s/\[%(.+?)%\]/eval $1/eg;
io($to)->print($text);
}
}

sub {
my $env = shift;

if (exists $static_files{ $env->{PATH_INFO} }) {
my $fn = $static_files{ $env->{PATH_INFO} } ? $static_files{ $env->{PATH_INFO} }->{fn} : './' . $env->{PATH_INFO};
my $headers = $static_files{ $env->{PATH_INFO} } ? $static_files{ $env->{PATH_INFO} }->{headers} : [];
open my $fh, '<' . $fn;
return [200, $headers, $fh];
}

return [
404,
['Content-Type' => 'text/plain; charset=utf-8'],
['Здесь рыбы нет']
];
};
Binary file added bunny.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added circle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frame.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
78 changes: 78 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<!DOCTYPE html>
<html style="margin: 0px;overflow: hidden">
<head>
<title>webq2</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pixi.js/4.5.1/pixi.min.js"></script>
<script src="js/Construction.js"></script>
<script src="js/Particle.js"></script>
<script src="js/Character.js"></script>
</head>
<body style="background-color:#CCC;margin: 0px;overflow: hidden">

<script>
// The application will create a renderer using WebGL, if possible,
// with a fallback to a canvas render. It will also setup the ticker
// and the root stage PIXI.Container
const app = new PIXI.Application();
app.renderer.autoResize = true;
app.renderer.resize(window.innerWidth, window.innerHeight);
document.body.appendChild(app.view);

const enemies = [];
let bunny;
const particles = [];

// const particle_container = new PIXI.particles.ParticleContainer(10000, {
// scale: true,
// position: true,
// rotation: true,
// alpha: true,
// uvs: true,
// });
// const particle_container = new PIXI.Container();
const particle_container = app.stage;

const floors = [];
const walls = [];
// var debug_text = new PIXI.Text('0', new PIXI.TextStyle({fill: '#ffffff'}));
// debug_text.x = 0;
// debug_text.y = 0;
// app.stage.addChild(debug_text);

// load the texture we need
PIXI.loader
.add('bunny', 'bunny.png')
.add('circle', 'circle.png')
.load((loader, resources) => {
generate_level();
bunny = new Character(app);

// Listen for frame updates
app.ticker.add(() => {
const dt = 0.016;//app.ticker.elapsedMS * 0.001;

bunny.update(dt);
enemies.forEach( char => {
char.update(dt);
});
particles.forEach(particle => {
if (particle === undefined) {
return;
}
particle.update(dt);
});

// debug_text.text =
// bunny.x.toFixed(3) + ';' + bunny.y.toFixed(3) + "\n" +
// bunny.dx.toFixed(3) + ';' + bunny.dy.toFixed(3)
// ;
});

//Attach event listeners
document.onkeydown = event => bunny.handle_keydown(event);
document.onkeyup = event => bunny.handle_keyup(event);
document.onclick = event => bunny.handle_click(event);
});
</script>
</body>
</html>
Loading

0 comments on commit 67aadb7

Please sign in to comment.