浏览代码

Changes in steering of snake, no self-eating anymore. Furthermore a dummy start page.

Colleagues 10 年之前
父节点
当前提交
ce196e5d55
共有 3 个文件被更改,包括 125 次插入9 次删除
  1. 60 0
      css/start.css
  2. 30 9
      js/controller.js
  3. 35 0
      start.html

+ 60 - 0
css/start.css

@@ -0,0 +1,60 @@
+
+ul {
+    list-style-type: none;
+    margin: 0;
+    padding: 0;
+    overflow: hidden
+}
+
+
+a:link, a:visited {
+    display: block;
+    width: 120px;
+    font-weight: bold;
+    color: #FFFFFF;
+    background-color: #F44336;
+    text-align: center;
+    padding: 4px;
+    text-decoration: none;
+    text-transform: uppercase
+}
+
+a:hover, a:active {
+    background-color: #F88000
+}
+
+.head-container {
+	text-align: center;
+	font-size:48px;
+	color: #FFFFFF;
+    background-color: #F44336;
+	padding:1px 16px;
+	width: 100%
+}
+
+.container {
+	text-align: center;
+	color: #FFFFFF;
+    background-color: #F44336;
+	padding:1px 16px;
+	margin-left: auto;
+    margin-right: auto;
+    width: 100%;
+	font-size:25px
+}
+
+.foot-container {
+	color: #FFFFFF;
+    background-color: #F44336;
+	padding:5px 25px;
+	width: 100%
+}
+
+.foot-left {
+	text-align: left;
+	font-size:18px;
+}
+.foot-right {
+	text-align: right;
+	font-size:18px;
+}

+ 30 - 9
js/controller.js

@@ -64,20 +64,41 @@ Controller.prototype.bind_events = function(){
     var c = this;
 	window.onkeydown = function(e){
 		var direction = null;
+		var dir = {x: c.snake.physicists[0].direction.x, y: c.snake.physicists[0].direction.y};
+
 		switch (e.keyCode){
 			case 37:
-				direction = {x: -1, y: 0};
-				break;
+				if(dir.x == 1)
+					{
+						break;}
+				else {
+						direction = {x: -1, y: 0};
+						break;
+					}
 			case 38:
-				direction = {x: 0, y: -1};
-				break;
+				if(dir.y == 1)
+					{
+						break;}
+				else {
+						direction = {x: 0, y: -1};
+						break;
+					}
 			case 39:
-				direction = {x: 1, y: 0};
-				break;
+			if(dir.x == -1)
+					{
+						break;}
+				else {
+						direction = {x: 1, y: 0};
+						break;
+				}
 			case 40:
-				direction = {x: 0, y: 1};
-				break;
-
+				if(dir.y == -1)
+					{
+						break;}
+				else {
+						direction = {x: 0, y: 1};
+						break;
+					}
 		}
 		if (direction){
 			c.turn_snake(direction);

+ 35 - 0
start.html

@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>SNAKY PARTCILE</title>
+</head>
+
+<link rel="stylesheet" href="./css/start.css">
+
+<body>
+
+<header class="head-container"> SNAKY PARTICLE </header>
+
+<article class="container">
+  <ul>
+    <li><a href="index.html">Start Game</a></li>
+    <li><a href="settings.html">Settings</a></li>
+    <li><a href="scorelist.html">Scorelist</a></li>
+    <li><a href="about.html">About</a></li>
+    <li><a href="end.html">Quit</a></li>
+  </ul>
+</article>
+
+
+<footer class="foot-container">
+  <div class="left">
+    <h6>Snaky Particle: An educational particle physics game.</h6>
+  </div>
+  <div align="right">
+    <h6>@CERN-Webfest 2015</h6>
+  </div>
+</footer>
+
+</body>
+
+</html>