Browse Source

Added Zombie Panda to the high score system

pull/1/head
jrtechs 7 years ago
parent
commit
c55850e20e
7 changed files with 62 additions and 13 deletions
  1. +9
    -0
      games/bamboofield.html
  2. +3
    -0
      games/bamboofield.php
  3. +1
    -1
      games/highscore.php
  4. +5
    -0
      games/insertScore.php
  5. +1
    -1
      games/userscores.php
  6. +22
    -3
      games/zombiePanda.html
  7. +21
    -8
      games/zombiePanda.php

+ 9
- 0
games/bamboofield.html View File

@ -1,5 +1,14 @@
<script> <script>
window.addEventListener("keydown", function(e)
{
// space and arrow keys
if([32, 37, 38, 39, 40].indexOf(e.keyCode) > -1)
{
e.preventDefault();
}
}, false);
window.onload = function() window.onload = function()
{ {
var canvasBFc = document.getElementById("canvasBF"); var canvasBFc = document.getElementById("canvasBF");

+ 3
- 0
games/bamboofield.php View File

@ -1,6 +1,9 @@
<?php <?php
$dir = 2; $dir = 2;
//used for high score
$game_id = 1;
//ini_set('display_errors', 1); //ini_set('display_errors', 1);
include '../includes/header.php'; include '../includes/header.php';

+ 1
- 1
games/highscore.php View File

@ -4,7 +4,7 @@
echo '<h1 class="w3-text-teal"><center>High Scores</center></h1>'; echo '<h1 class="w3-text-teal"><center>High Scores</center></h1>';
$q = "select * from scores order by score desc limit 20";
$q = "select * from scores where game = '$game_id' order by score desc limit 20";
$r = mysqli_query($dbc, $q); $r = mysqli_query($dbc, $q);
echo '<div class="w3-responsive w3-card-4"><table class="w3-table w3-striped w3-bordered"><thead>'; echo '<div class="w3-responsive w3-card-4"><table class="w3-table w3-striped w3-bordered"><thead>';
echo '<tr class="w3-theme"> echo '<tr class="w3-theme">

+ 5
- 0
games/insertScore.php View File

@ -32,6 +32,11 @@
header("Location: bamboofield.php"); header("Location: bamboofield.php");
} }
else if($i_game == 2)
{
header("Location: zombiePanda.php");
}
} }
?> ?>

+ 1
- 1
games/userscores.php View File

@ -6,7 +6,7 @@
{ {
echo '<h1 class="w3-text-teal"><center>User\'s Personal Records</center></h1>'; echo '<h1 class="w3-text-teal"><center>User\'s Personal Records</center></h1>';
$q = "select * from scores where user_id='" . $_SESSION['user_id'] . "' order by score desc limit 20";
$q = "select * from scores where user_id='" . $_SESSION['user_id'] . "' and game='$game_id' order by score desc limit 20";
$r = mysqli_query($dbc, $q); $r = mysqli_query($dbc, $q);
echo '<div class="w3-responsive w3-card-4"><table class="w3-table w3-striped w3-bordered"><thead>'; echo '<div class="w3-responsive w3-card-4"><table class="w3-table w3-striped w3-bordered"><thead>';
echo '<tr class="w3-theme"> echo '<tr class="w3-theme">

+ 22
- 3
games/zombiePanda.html View File

@ -1,4 +1,14 @@
<script> <script>
window.addEventListener("keydown", function(e)
{
// space and arrow keys
if([32, 37, 38, 39, 40].indexOf(e.keyCode) > -1)
{
e.preventDefault();
}
}, false);
window.onload = function() window.onload = function()
{ {
var canvas = document.getElementById("canvasZP"); var canvas = document.getElementById("canvasZP");
@ -9,7 +19,8 @@
function playZP() function playZP()
{ {
var animate = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function (callback) {
var animate = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function (callback)
{
window.setTimeout(callback, 1000 / 60) window.setTimeout(callback, 1000 / 60)
}; };
var canvas = document.getElementById("canvasZP"); var canvas = document.getElementById("canvasZP");
@ -324,8 +335,8 @@
var sent = false;
var tic = function() var tic = function()
{ {
if(dead) if(dead)
@ -338,6 +349,14 @@
context.fillStyle = "rgba(255, 255, 255, 1)"; //green context.fillStyle = "rgba(255, 255, 255, 1)"; //green
context.font= "20px Georgia"; context.font= "20px Georgia";
context.fillText("You died with a score of " + score,200,340); context.fillText("You died with a score of " + score,200,340);
if(!sent)
{
document.body.innerHTML += '<form id="dynForm" action="insertScore.php" method="post"><input type="hidden" name="game_new_score" value=true><input type="hidden" name="game" value=2><input type="hidden" name="user_id_score" value=<?php echo $_SESSION['user_id']; ?>><input type="hidden" name="score_validate" value=' + score + '></form>';
document.getElementById("dynForm").submit();
sent = !sent;
}
} }
else else

+ 21
- 8
games/zombiePanda.php View File

@ -1,22 +1,35 @@
<?php <?php
//5-16-17
$dir = 2; $dir = 2;
$game_id = 2;
//ini_set('display_errors', 1);
include '../includes/header.php'; include '../includes/header.php';
echo '<br><div class="w3-row">
<div class="w3-twothird w3-container ">';
echo '<div class="w3-row w3-padding-32">';
echo '<div class="w3-half w3-container">';
include('zombiePanda.html'); include('zombiePanda.html');
echo '</div><div class="w3-third w3-container">';
echo '</div><div class="w3-half w3-container">';
//include('../includes/profile.php');
include('highscore.php');
//high scores
include('../includes/profile.php');
echo '</div></div>';
echo '<div class="w3-row w3-padding-32">';
echo '<div class="w3-half w3-container">';
//edit user
include('../user/profile.php');
echo '</div>';
echo '</div>';
echo '</div><div class="w3-half w3-container">';
include('userscores.php');
echo '</div></div>';
include '../includes/footer.php'; include '../includes/footer.php';

Loading…
Cancel
Save