Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added HomePage.html
Empty file.
6 changes: 6 additions & 0 deletions User_Memory.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
briseida
123456
Briseida
john
0
1
Empty file added app.css
Empty file.
132 changes: 132 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
"use strict";
var gameStart = null,
gameSpeed = null,
gameArea = null,
gameAreaContext = null,
gameAreaWidth = 0,
gameAreaHeight = 0,
cellWidth = 0,
playerScore = 0,
snake = null,
snakeFood = null,
snakeDirection = null,
speedSize = 0,
timer = null;

function initialize() {
gameStart = document.querySelector("#gameStart");
gameSpeed = document.querySelector("#gameSpeed");
gameArea = document.querySelector("#gameArea");
gameAreaContext = gameArea.getContext("2d");
gameAreaWidth = 400;
gameAreaHeight = 600;
cellWidth = 20;
gameArea.width = gameAreaWidth;
gameArea.height = gameAreaHeight;

gameStart.onclick = function () {
this.disabled = true;
startGame();
}
}

function startGame() {
playerScore = 0;
snakeDirection = "right";
speedSize = parseInt(gameSpeed.value);

if (speedSize > 9) {
speedSize = 9;
} else if (speedSize < 0) {
speedSize = 1;
}

snake = [];
snake.push({ x: 0, y: cellWidth });

createFood();

clearInterval(timer);
timer = setInterval(createGameArea, 500 / speedSize);
}

function createFood() {
snakeFood = {
x: Math.round(Math.random() * (gameAreaWidth - cellWidth) / cellWidth),
y: Math.round(Math.random() * (gameAreaHeight - cellWidth) / cellWidth),
};
}

function createGameArea() {
var snakeX = snake[0].x;
var snakeY = snake[0].y;

gameAreaContext.fillStyle = "#FFFFFF";
gameAreaContext.fillRect(0, 0, gameAreaWidth, gameAreaHeight);
gameAreaContext.strokeStyle = "#000000";
gameAreaContext.strokeRect(0, 0, gameAreaWidth, gameAreaHeight);

if (snakeDirection == "right") {
snakeX++;
} else if (snakeDirection == "left") {
snakeX--;
} else if (snakeDirection == "down") {
snakeY++;
} else if (snakeDirection == "up") {
snakeY--;
}

if ((snakeX == -1) || (snakeX == gameAreaWidth / cellWidth) || (snakeY == -1) || (snakeY == gameAreaHeight / cellWidth) || Control(snakeX, snakeY, snake)) {
writeScore();
clearInterval(timer);
gameStart.disabled = false;
return;
}

if (snakeX == snakeFood.x && snakeY == snakeFood.y) {
var newHead = { x: snakeX, y: snakeY };
playerScore += speedSize;
createFood();
} else {
var newHead = snake.pop();
newHead.x = snakeX;
newHead.y = snakeY;
}

snake.unshift(newHead);

for (var i = 0; i < snake.length; i++) {
createSquare(snake[i].x, snake[i].y);
}

createSquare(snakeFood.x, snakeFood.y);
}

function Control(x, y, array) {
for (var i = 0; i < array.length; i++) {
if (array[i].x == x && array[i].y == y) return true;
}
return false;
}

function writeScore() {
gameAreaContext.font = "50px sans-serif";
gameAreaContext.fillStyle = "#FF0000";
gameAreaContext.fillText("Score: " + playerScore, (gameAreaWidth / 2) - 100, gameAreaHeight / 2);
}

function createSquare(x, y) {
gameAreaContext.fillStyle = "#000000";
gameAreaContext.fillRect(x * cellWidth, y * cellWidth, cellWidth, cellWidth);
}

function changeDirection(e) {
var keys = e.which;
if (keys == "40" && snakeDirection != "up") snakeDirection = "down";
else if (keys == "39" && snakeDirection != "left") snakeDirection = "right";
else if (keys == "38" && snakeDirection != "down") snakeDirection = "up";
else if (keys == "37" && snakeDirection != "right") snakeDirection = "left";
}

window.onkeydown = changeDirection;
window.onload = initialize;
14 changes: 14 additions & 0 deletions login.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
</head>

<body>
<form>
<label for="email">eMail:</label><br>
<input type="text" id="email" name="email"><br>
<label for="password">Password:</label><br>
<input type="text" id="password" name="password">
<input type="submit" value="Submit">
</form>
</body>
51 changes: 51 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@


with open('User_Memory.txt') as f:
lines = f.readlines()
f.close()



class User_1:
def __init__(self,Name,Access,Status):
self.Name = Name
self.Access = Access
self.Status = Status

def get_Name(self):
return(self.Name)
def get_Access():
return(self.Access)
def get_Status():
return(self.Status)

def create_user(createdby,Name,Access,Status):
Write_to_User_Memory(Name,Access,Status)
Name = User_1(Name,Access,Status)
return(Name)

with open('User_Memory.txt') as f:
lines = f.readlines()
f.close()


def Write_to_User_Memory(Name,Access,Status):
lines = 0
with open('User_Memory.txt') as f:
lines = f.readlines()
f.close()
xxyy = len(lines)
xx = [Name,Access,Status,]
x = 0
with open('User_Memory.txt',"a") as ft:
while x <= 2:
ft.write('\n')
ft.write(str(xx[x]))

x = x + 1
ft.close()





Loading