PDA

Click to See Complete Forum and Search --> : My Killer App!


Mark Sreeves
Jun 8th, 2000, 03:23 PM
I wrote this!

it's a "Snake" game the same as on Nokia phones but high-scores are kept in a database on an internet server

it is written in VB5.

when/if you go to this page you'lll be prompted for a username and password.

This is then entered into the database and when you download the exe, your highscores will be posted back to the site.

Yeah! it took me ages to work out how to transfer the username from the website to the pc.


http://www6.ewebcity.com/coolsite/snake/


I can guarentee that it will NOT format your harddrive or do anything nasty to you or your PC

Ianpbaker
Jun 8th, 2000, 03:34 PM
Very Good Mark

A little bit of Nostalgia for you. Snake originally came when DOS was around and a version came with QBASIC that you could tweek to make more interesting, Also A game came called Monekeys came with QBASIC and consisted of two gorillas standing on top of Buildings, chucking explosive bananas at each other. The best part of the game was that you could tweek the size of the explosions to take out half the screen at a time.

All the Best

Ian

Chris
Jun 8th, 2000, 05:31 PM
Cool Man & Damn Fast... but I still get on top of you... :)

Hall of Fame for Snake2
Name Score

Chris 165

ian 65

Mark Sreeves 35


[Edited by Chris on 06-09-2000 at 02:38 PM]

Mark Sreeves
Jun 8th, 2000, 05:50 PM
I forgot to mention. The game has to be downloaded on the PC you want to run it on for the high scores to work.

If you copy it to another PC the highscores probably won't work.

WHY?

Then you register and download the .zip file your usename is sent to your browser as a cookie.

Then, when you run it for the fist time the user name is read from the cookie and stored in your registry.

When you beat your previous high score, your username is read from the registry and posted back to the website along with your new high score.

The cookies are fisrt read by connecting to the site again

getcookie.asp

Normally, you would put stuff in the asp to prevent it from being cached but I didn't bother to make it easier to read the page from VB.

The reason why I'm telling you this is that if you "register" again your new username will be stored in a cookie on your PC but when you run the program the getCookie.asp will be retrieved from the cache so the old username will be used still.

I could fix this but I can't be bothered!

Mark Sreeves
Jun 11th, 2000, 06:08 PM
I was asked for some instructions

Use your arrow keys to steer the snake to eat the food

Crypt
Jun 11th, 2000, 08:01 PM
great job, I remember a game like this from back when I had a 386, and you had to eat either red or yellow apples or something, and woohoo I got the highest score (I doubt for very long but anyways)

Hall of Fame for Snake2
Name Score

Crypt 195

Chris 165

ian 65

Mark Sreeves 40

Sam Finch 0

Shabra 0

r 0

gfdgfd 0

Did you write the asp yourself for the high scores? or did you get it from somewhere? just wondering because I wouldn't mind having a high scores thingy on a game (if I ever make one lol), if you didn't make the active server page yourself (I wouldn't have a clue how to make one) would you mind telling where you got it from and how to install one on a website? if not don't worry about

thanx and great job.

oh yeah and I like your version better than the one back from the 386 days (I always used to die lol because you couldn't go over yourself when you became a big snake).

Mark Sreeves
Jun 11th, 2000, 08:25 PM
Crypt

Yeah I wrote it all myself.
It's trivial really stuff really
this is basically the code to update the remote database.

Mine is a bit more complicated because I use the same script to show the high scores as to post the updates.

this code goes in an ASP file and I use an internet transfer control within the vb app to call it

I've changed the names of the text fields after the line 'updating database details and anyone who knows anything about ASPs will know why! :)






<%@ Language=VBScript%>
<HTML>
<head>
<!-- Prevent the page from being cached -->
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
</head>
<BODY>
<%

dim strSQL
dim rst
dim conn


Set conn = Server.CreateObject("ADODB.Connection")
conn.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=c:\Snake2.mdb")

'updating database details
name = request("theNameOfYourNameField")
pass = request("theNameOfYourPasswordField")
score = request("theNameOfYourHighScorefield")

strSQL = "UPDATE tblScores set score= '" & score & "' WHERE name= '" & name & "'AND password='" & pass & "';"

conn.Execute(strsql)

conn.Close
set conn = nothing

%>

</BODY>
</HTML>



I didn't realise that you could go over yourself!:(

This is version 2. Version 1 which posted to a Personal webserver on my PC didn't allow you to.

The snake is an array of shape controls. With my version 1 each time the snake moved, the every shape was moved this made it slow down as the snake got longer.

This version uses an array of shapes but only moves the end shape to the front each time it moves.

After I re-coded this bit I didn't bother to test it much because it seemed to work OK!

It's to late to fix it now...

Crypt
Jun 11th, 2000, 10:32 PM
thanx for that asp script, I've had little to none experience with asp before, just a couple of questions though 1. do you have to create a database file and upload it first or will it just create one if it doesn't exist? and second how do you get an asp page to read the results to print the top scores?.

well I like that you dont loose if you go over your snake I actually stood a chance at winning the game when I found that out lol.

Mark Sreeves
Jun 11th, 2000, 10:38 PM
You have to create a databse and then upload it

Here's the script for reading the database

This is for the one on PWS not the website


<%@ Language=VBScript%>
<HTML>
<head>
<!-- Prevent the page from being cached -->
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
</head>
<BODY>
<%

dim strSQL
dim rst

dim conn


Set conn = Server.CreateObject("ADODB.Connection")


conn.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=c:\Snake2.mdb")


Response.Write "<TABLE border=0 cellPadding=0 cellSpacing=0 width=200 VALIGN='TOP'>"
Response.Write "<TR><TD COLSPAN=2><h3>Hall of Fame for Snake2</h3></TD></TR>"
Response.Write("<TR><TD WIDTH=100 VALIGN='TOP'><B>Name</B></TD><TD WIDTH=100 VALIGN='TOP'><B>Score</B></TD></TR><BR>")

strSQL = "SELECT * FROM tblScores ORDER BY score DESC;"

Set rst = conn.Execute(strSQL)
while not rst.eof
Response.Write("<TR><TD WIDTH=100 VALIGN='TOP'>" & rst("name") & "</TD><TD WIDTH=100 VALIGN='TOP'>" & rst("score") & "</TD></TR><BR>")
rst.movenext

wend
Response.Write"</table>"

set rst = nothing


conn.Close
set conn = nothing

%>

</BODY>
</HTML>

Crypt
Jun 11th, 2000, 11:05 PM
lol I think i will quit asp before I even get started lol, wouldn't have a clue how to set that up.

that snake game is addictive though lol but once you get up to 400 points it starts getting hard to tell your head from your tail and where the food is lol.

Mih_Flyer
Jun 17th, 2000, 11:19 AM
hey man, i tried to go to http://www6.ewebcity.com/coolsite/snake/ but i couldn't,,, what's wrong with this url,,is it right or what?

SteveCRM
Jun 18th, 2000, 07:22 AM
I can't try it either,

Mih_Flyer
Jun 18th, 2000, 07:29 AM
I want to see this game, what ever it takes i wan to see it, please e-mail it to me if you can,,Thanx

Mark Sreeves
Jun 18th, 2000, 02:45 PM
ewebcity are currently performing some upgrades to their servers so if you really want it you'll have to try again later.

It's nothing to get excited about anyway!


Mih_Flyer, I can't email it to you because it keeps the high scores on the server and you have to entrer your name on the website for so your highscores are accepted.

It's all a bit shaky anyway.