master
Aaron Mueller 8 years ago
parent 7c6618800c
commit 83131b7acc
  1. 82
      fuTris.js
  2. 10
      index.html
  3. 36
      main.css
  4. BIN
      screenshot_big.png
  5. BIN
      screenshot_small.png
  6. BIN
      submission/assets/drop.wav
  7. BIN
      submission/assets/move.wav
  8. BIN
      submission/assets/point.wav
  9. BIN
      submission/assets/rotate.wav
  10. 1
      submission/fuTris.js
  11. 24
      submission/index.html
  12. BIN
      submission/js13kgames-aaronfischer.zip
  13. 36
      submission/main.css

@ -7,6 +7,8 @@ var field = [];
var background = [];
var game_running = true;
var subframe = 0;
var moved_steps = 0;
var speed = 100;
var points = 0;
var level = 0;
@ -143,6 +145,12 @@ function draw() {
// Level
draw_text(level, 30, 420, 230);
draw_text('Level', 13, 420, 250);
// Game over?
if (!game_running) {
draw_text("Game over", 60, 40, 250);
draw_text("Press R for a new game", 20, 140, 270);
}
}
function noice(offset, level) {
@ -267,9 +275,10 @@ addEventListener('keydown', function(event) {
if (game_running) loop();
}
// TODO: Back to the main menu
if (event.keyCode == 27 || event.keyCode == 121)
console.log('Implement me.');
// Restart the game
if (event.keyCode == 82 && !game_running) {
init();
}
});
function init() {
@ -277,39 +286,19 @@ function init() {
points = 0;
level = 0;
stones = 0;
// Load the assets
assets.rotate.load();
assets.drop.load();
assets.move.load();
assets.point.load();
game_running = true;
subframe = 0;
moved_steps = 0;
// Init the audio chanels
for (var a=0; a<10; a++) {
audio_chanels[a] = {
channel: new Audio(),
finished: -1
};
}
// Initialize the game field and the background
for (var x=0; x<10; x++) {
field[x] = [];
background[x] = [];
for (var y=0; y<16; y++) {
var mod = noice(15, 15);
background[x][y] = '' + mod + mod + mod;
field[x][y] = 0;
}
}
for (var x=0; x<10; x++)
for (var y=0; y<16; y++)
field[x][y] = 0;
// Start the game
next_shape();
loop();
}
var subframe = 0;
var moved_steps = 0;
function loop() {
// Move the next step
subframe++;
@ -324,9 +313,9 @@ function loop() {
clear_full_lines();
next_shape();
// Restart the game?
// Game over?
if (moved_steps === 0 || will_collide(0, {left: 4, top: 0}))
init();
game_running = false;
moved_steps = 0;
return true;
}
@ -338,5 +327,32 @@ function loop() {
if (game_running) setTimeout(loop, 5);
}
function setup() {
// Load the assets
assets.rotate.load();
assets.drop.load();
assets.move.load();
assets.point.load();
// Init the audio chanels
for (var a=0; a<10; a++) {
audio_chanels[a] = {
channel: new Audio(),
finished: -1
};
}
// Initialize the game field and the background
for (var x=0; x<10; x++) {
field[x] = [];
background[x] = [];
for (var y=0; y<16; y++) {
var mod = noice(15, 15);
background[x][y] = '' + mod + mod + mod;
field[x][y] = 0;
}
}
}
setup();
init();
loop();

@ -7,7 +7,17 @@
<link rel="stylesheet" href="main.css">
</head>
<body>
<h1>fuTris</h1>
<p>A <a href="http://js13kgames.com/">js13kGames 2014</a> entry (<a href="http://github.com/f0086/js13kgames-2014">source</a>)
by <a href="https://aaron-mueller.de/">Aaron Fischer</a>.</p>
<canvas id="fuTris"></canvas>
<p>Use the arrow keys to move (<span></span>, <span></span>, rotate
(<span></span>) and drop (<span></span>) stones. Press <span>P</span> for
pause the game. If you messed up, restart with <span>R</span>. Vim-users
will also find a way to play :)</p>
<audio src="assets/rotate.wav" id="rotate-sound" autostart="false"></audio>
<audio src="assets/drop.wav" id="drop-sound" autostart="false"></audio>
<audio src="assets/move.wav" id="move-sound" autostart="false"></audio>

@ -0,0 +1,36 @@
html {
background-color: #333;
color: #bbb;
font-family: Verdana, "DejaVu Sans";
}
body {
margin: auto;
width: 514px;
}
canvas {
border: 2px solid #444;
}
h1 {
color: white;
text-align: center;
font-size: 70px;
margin: 0;
}
a {
color: #4f6c19;
}
a:hover {
color: #8fc32e;
}
span {
background-color: #444;
border-radius: 3px;
padding: 2px 5px;
font-weight: bold;
color: white;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

@ -0,0 +1,24 @@
<!doctype html>
<html lang="">
<head>
<meta charset="utf-8">
<title>fuTris -- a js13kGames entry</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="main.css">
</head>
<body>
<h1>fuTris</h1>
<p>A <a href="http://js13kgames.com/">js13kGames 2014</a> entry (<a href="http://github.com/f0086/js13kgames-2014">source</a>)
by <a href="https://aaron-mueller.de/">Aaron Fischer</a>.</p>
<canvas id="fuTris"></canvas>
<p>Use the arrow keys to move (<span></span>, <span></span>, rotate
(<span></span>) and drop (<span></span>) stones. Press <span>P</span> for
pause the game. If you messed up, restart with <span>R</span>. Vim-users
will also find a way to play :)</p>
<audio src="assets/rotate.wav" id="rotate-sound" autostart="false"></audio>
<audio src="assets/drop.wav" id="drop-sound" autostart="false"></audio>
<audio src="assets/move.wav" id="move-sound" autostart="false"></audio>
<audio src="assets/point.wav" id="point-sound" autostart="false"></audio>
<script src="fuTris.js"></script>
</body>
</html>

@ -0,0 +1,36 @@
html {
background-color: #333;
color: #bbb;
font-family: Verdana, "DejaVu Sans";
}
body {
margin: auto;
width: 514px;
}
canvas {
border: 2px solid #444;
}
h1 {
color: white;
text-align: center;
font-size: 70px;
margin: 0;
}
a {
color: #4f6c19;
}
a:hover {
color: #8fc32e;
}
span {
background-color: #444;
border-radius: 3px;
padding: 2px 5px;
font-weight: bold;
color: white;
}
Loading…
Cancel
Save