Sign in to follow this  
  • entries
    38
  • comments
    87
  • views
    34258

Hacktacular

Sign in to follow this  
Patbert

287 views

Psycho Boy 3D Progress:

I'm testing out the new online highscore for psychoboy, check out the Hack my highscore thread. I'm working hard on making it at least semi-hack proof, at least secure enough to stop someone like XY.

In other news:
The results came through for my degree and I got a first, hooray!
Sign in to follow this  


5 Comments


Recommended Comments

That hand-drawn house in the screenshot in your previous journal entry kicks much ass. I think it would be cool if somebody made an entire game with hand-drawn textured models like that. [grin]

Share this comment


Link to comment
Thanks, that was originally a placeholder texture to test it out but I decided to keep it. The game does have quite a mishmash of styles due to the fact I have no artistic talent and I was learning OpenGL and such at the time. Someone did make a hand-drawn space invaders game.

Share this comment


Link to comment
Congrats. Make sure you make a extendable highscore system. I got stuck with mine as all I included were their name and score. Another good thing would be to have a number key embedded in the highscores so that you could adapt the same system to a completely different game.

Share this comment


Link to comment
Good point, psychoboy does pass a gameid value via the url but its not actually used server side. Hopefully I can extend it to other games without too much of a problem.

Share this comment


Link to comment

<% Option Explicit %>

<html><head>
<title>Patbert's High Score Table</title>
</head><body text=#FFFFFF bgcolor=#000000>

HIGHSCORE TABLE



<%

const databaseFile="/psychoscore/database/highscore.mdb" 'Database that stores the scores
const gameIdColumn=0, positionColumn=1, scoreColumn=2, levelColumn=3, playerColumn=4 'column numbers for fields
const MAXSCORES=80 ' Maximum number of highscores
Dim SQLStatement 'SQL statement used to retrieve highscores
' SQL will retrieve all highscores for the requested GAMEID (passed via URL):
SQLStatement = "SELECT * FROM hiscore WHERE (gameid="∫(request("gameid"))&") ORDER BY position"

Dim Conn, RS 'Declares the Conn (Connection) and RS (Recordset) variables
dim currRecord, targetRecord, nextRecord 'arrays for highscores
Dim result, message 'Stores HTML of highscore table (result) and a message (message)
Dim positionFound 'boolean, true if submitted highscore has been found
Dim lastPosition 'Stores last highscore position
Dim scoreValid 'Boolean: true if submitted highscore is valid

Set Conn = Server.CreateObject("ADODB.Connection")
Set RS = Server.CreateObject("ADODB.Recordset")

targetRecord=getTargetRecord 'Get submitted highscore (target score)
' Check player's name is not empty
if targetRecord(playerColumn)="" then scoreValid=false else scoreValid=true
positionFound=false
lastPosition=-1

'Open database for writing (how this is done depends on your provider - consult your provider's documentation)
Conn.Open "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath(databaseFile)
RS.Open SQLStatement, Conn, 3, 3 'Open the database for writing while allowing others to still read it.

if not RS.EOF then RS.MoveFirst 'If table is not empty go to first record
Do Until RS.EOF 'Loop until no records

currRecord=getRecord(RS) 'Get record from database
if isDuplicate(currRecord,targetRecord) then scoreValid=false 'If submitted score is already in database, score is invalid

'If score is valid and this is the position to insert the target highscore:
if scoreValid and positionFound=false and int(currRecord(scoreColumn))<=int(targetRecord(scoreColumn)) then
positionFound=true
nextRecord=currRecord 'Set the next record as the current one
targetRecord(positionColumn)=currRecord(positionColumn) 'Set position number same as current one
nextRecord(positionColumn)=nextRecord(positionColumn)+1 'Move position of next record on one
currRecord=targetRecord 'Set the current record as the submitted record
saveRecord(currRecord) 'Save to database
result=result+recordToString(currRecord,"<td align=center bgcolor=#800000>") 'Add to table
message="Well done! You got to position #"&(targetRecord(positionColumn)+1)&" in the highscore table!

"

elseif positionFound then 'If current record is below the submitted record
swapArray currRecord,nextRecord 'Move records down to accommadate the inserted highscore
nextRecord(positionColumn)=nextRecord(positionColumn)+1 'add one to next record
saveRecord(currRecord) 'Save to database
result=result+recordToString(currRecord,"<td align=center>") 'Display to table

else 'If the target highscore hasn't been found yet
result=result+recordToString(currRecord,"<td align=center>") 'Just display to table
end if

lastPosition=currRecord(positionColumn)
RS.MoveNext 'Go to next record
Loop

if scoreValid then
if positionFound=false and lastPosition>=MAXSCORES-1 then 'If the submitted highscore is off the table
message="Sorry, you did not qualify for the highscore table

"
elseif positionFound=false then 'If submitted highscore is on the bottom of the highscore table
targetRecord(positionColumn)=lastPosition+1 'Set position to the last highscore plus one
addRecord(targetRecord) 'Add record to database
message="Well done! You got to position #"&(targetRecord(positionColumn)+1)&" in the highscore table!

"
result=result+recordToString(targetRecord,"<td align=center bgcolor=#800000>") 'Display
else 'If submitted highscore has already been added
addRecord(nextRecord) 'Add the last record that has been moved along
result=result+recordToString(nextRecord,"<td align=center>") 'Display
end if
end if

RS.Close 'Close database
Conn.Close

Response.Write message 'Display message
Response.Write "<table border=0 cellspacing=3><tr>" 'Display table header
Response.Write "<td align=center bgcolor=#333333> POSITION </td>"
Response.Write "<td align=center bgcolor=#333333> SCORE </td>"
Response.Write "<td align=center bgcolor=#333333> LEVEL </td>"
Response.Write "<td align=center bgcolor=#333333> PLAYER </td>"
Response.Write result 'Display highscores

'Returns a string for adding into the HTML table
function recordToString(detail,prefix)
recordToString= "<tr>"&prefix& _
detail(positionColumn)+1&"</td>"&prefix& _ '1 is added to position as it is zero indexed
detail(scoreColumn)&"</td>"&prefix& _
detail(levelColumn)&"</td>"&prefix& _
detail(playerColumn)&"</td></tr>"
end function

'Edits current database record
sub saveRecord(detail)
RS.Fields("Player").Value =detail(playerColumn)
RS.Fields("Level").Value=detail(levelColumn)
RS.Fields("Score").Value=detail(scoreColumn)
RS.Update
end sub

'Adds new record to database
sub addRecord(detail)
RS.AddNew
RS.Fields("Position")=detail(PositionColumn)
RS.Fields("GameId").Value=detail(gameIdColumn)
saveRecord(detai

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now