2015.09.24
This commit is contained in:
parent
6cd585a6cb
commit
1f6c1a9d86
4 changed files with 21 additions and 94 deletions
|
@ -15,7 +15,7 @@ namespace SnakeGame
|
|||
public partial class Form1 : Form
|
||||
{
|
||||
private static Timer Timer;
|
||||
private static Timer SpeedTimer;
|
||||
//private static Timer SpeedTimer;
|
||||
private static bool timerenabled = false;
|
||||
public static Form1 Instance;
|
||||
public static bool TimerEnabled
|
||||
|
@ -45,13 +45,17 @@ namespace SnakeGame
|
|||
if (value && !timerenabled) //Only start if not running already
|
||||
{
|
||||
Timer.Start();
|
||||
SpeedTimer.Start();
|
||||
//SpeedTimer.Start();
|
||||
}
|
||||
timerenabled = value;
|
||||
Instance.toolStripTextBox1.Enabled = !value;
|
||||
}));
|
||||
}
|
||||
}
|
||||
public static void SetTimer(int remtime)
|
||||
{
|
||||
Timer.Interval -= remtime;
|
||||
}
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
@ -73,7 +77,7 @@ namespace SnakeGame
|
|||
if (TimerEnabled)
|
||||
Timer.Start();
|
||||
};
|
||||
SpeedTimer = new Timer();
|
||||
/*SpeedTimer = new Timer();
|
||||
SpeedTimer.Interval = 10000;
|
||||
SpeedTimer.Tick += delegate
|
||||
{
|
||||
|
@ -82,7 +86,7 @@ namespace SnakeGame
|
|||
Game.Length++;
|
||||
if (!TimerEnabled)
|
||||
SpeedTimer.Stop();
|
||||
};
|
||||
};*/
|
||||
}
|
||||
|
||||
private void Form1_Load(object sender, EventArgs e)
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace SnakeGame
|
|||
public static Label ScoreLabel;
|
||||
public static Label LivesLabel;
|
||||
public static Panel DialogPanel;
|
||||
public static Player Player = new Player("Player", true);
|
||||
public static Player Player = new Player("Player", true, Color.LightGreen);
|
||||
/// <summary>
|
||||
/// Opposite of Form1.TimerEnabled
|
||||
/// </summary>
|
||||
|
@ -91,7 +91,7 @@ namespace SnakeGame
|
|||
}
|
||||
|
||||
//string matches = Network.Matches.Combine<NetMatch, string>((match, combiner) => combiner += match.Name + " " + match.Players.Count + "/" + match.MaxPlayers + " " + match.OwnerName + "\n");
|
||||
string inputs = "IP:\n";
|
||||
string inputs = "IP:";
|
||||
MSGBox.ShowMSGBox("Connect to game", inputs, MSGBoxType.MultipleInput, new EventHandler<string>(delegate (object s, string input)
|
||||
{
|
||||
IPAddress address;
|
||||
|
@ -215,6 +215,8 @@ namespace SnakeGame
|
|||
{
|
||||
Player.Score += 1000;
|
||||
ScoreLabel.ForeColor = Color.Blue;
|
||||
Game.Length++;
|
||||
Form1.SetTimer(100);
|
||||
Game.AddPoint();
|
||||
}
|
||||
else
|
||||
|
@ -231,11 +233,14 @@ namespace SnakeGame
|
|||
{
|
||||
Random rand = new Random();
|
||||
int x, y;
|
||||
int tries = 0;
|
||||
do
|
||||
{
|
||||
x = rand.Next(GameField.GetLength(0) - 1);
|
||||
y = rand.Next(GameField.GetLength(1) - 1);
|
||||
} while (GameField[x, y].Tick != 0 && GameField[x, y].Type == SquareType.Wall);
|
||||
tries++;
|
||||
//} while (GameField[x, y].Tick != 0 && GameField[x, y].Type == SquareType.Wall);
|
||||
} while (GameField[x, y].Tick != 0 && tries < 10);
|
||||
GameField[x, y].Tick = -1;
|
||||
GameField[x, y].Type = SquareType.Point;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ namespace SnakeGame
|
|||
{
|
||||
private static void ClientListenerThreadRun()
|
||||
{
|
||||
//TODO: Game over disconnect
|
||||
//TODO: Synchronised point placing on respawn
|
||||
try
|
||||
{
|
||||
|
|
|
@ -1,81 +0,0 @@
|
|||
<?php
|
||||
if(!isset($_POST['client']) || $_POST['client']=="")
|
||||
{
|
||||
echo "Welcome!<br>
|
||||
<a>Project home</a>";
|
||||
die();
|
||||
}
|
||||
else
|
||||
{
|
||||
//echo "Client data";
|
||||
$conn = mysqli_connect("mysql.hostinger.hu", "u821146919_games", "SLp7q9m60J", "u821146919_games");
|
||||
if($_POST['client']=="cheesecrescent")
|
||||
{ //GameList
|
||||
$res=mysqli_query($conn, "SELECT * FROM games");
|
||||
while($row=mysqli_fetch_array($res))
|
||||
{
|
||||
if(strlen($row['playernames'])==0)
|
||||
$namecount=0;
|
||||
else
|
||||
$namecount=count(explode(',', $row['playernames']));
|
||||
//echo ("Startdate: ".$row['startdate']." Time-1hr: ".(time()-60*60*1000));
|
||||
if($namecount==0 || strval($row['startdate'])<time()-60*60*1000)
|
||||
{
|
||||
mysqli_query($conn, "DELETE FROM games
|
||||
WHERE name='".$row['name']."'
|
||||
AND ownername='".$row['ownername']."'
|
||||
AND maxplayers='".$row['maxplayers']."'
|
||||
AND playernames='".$row['playernames']."'
|
||||
AND startdate='".$row['startdate']."'
|
||||
AND ip='".$row['ip']."'
|
||||
") or die(mysqli_error($conn));
|
||||
}
|
||||
else
|
||||
{
|
||||
echo $row['name']."|".$row['ownername']."|".$row['maxplayers']."|".$namecount."|".$row['playernames']."|".$row['ip']."|";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if($_POST['name']=="" || $_POST['maxplayers']=="" || $_POST['client']=="" || $_POST['ip']=="" || $_POST['action']=="")
|
||||
die("A field is or more fields are empty!");
|
||||
if($_POST['action']=="create")
|
||||
{
|
||||
mysqli_query($conn, "DELETE FROM games
|
||||
WHERE name='".$_POST['name']."'
|
||||
AND ownername='".$_POST['client']."'
|
||||
AND ip='".$_POST['ip']."'
|
||||
") or die(mysqli_error($conn));
|
||||
mysqli_query($conn, "INSERT INTO games
|
||||
(
|
||||
name, maxplayers, playernames, ownername, startdate, ip
|
||||
) VALUES (
|
||||
'".$_POST['name']."', '".$_POST['maxplayers']."', '".$_POST['client']."', '".$_POST['client']."', '".time()."', '".$_POST['ip']."'
|
||||
)") or die(mysqli_error($conn));
|
||||
echo "OK";
|
||||
}
|
||||
else if($_POST['action']=="change")
|
||||
{
|
||||
mysqli_query($conn, "UPDATE games SET playernames='".$_POST['playernames']."'
|
||||
WHERE name='".$row['name']."'
|
||||
AND ownername='".$row['ownername']."'
|
||||
AND ip='".$row['ip']."'
|
||||
") or die(mysqli_error($conn));
|
||||
echo "OK";
|
||||
}
|
||||
else if($_POST['action']=="remove")
|
||||
{ //Creating a new game on the same IP, with the same playername and same gamename will also remove. (^^)
|
||||
mysqli_query($conn, "DELETE FROM games
|
||||
WHERE name='".$_POST['name']."'
|
||||
AND ownername='".$_POST['client']."'
|
||||
AND ip='".$_POST['ip']."'
|
||||
") or die(mysqli_error($conn));
|
||||
echo "OK";
|
||||
}
|
||||
}
|
||||
}
|
||||
//WebPass: vhwfsQOv9E
|
||||
//fötöpö: (...sznpadmin) VKiSh7i1og
|
||||
|
||||
?>
|
Loading…
Reference in a new issue