Author Topic: New Game Project  (Read 5269 times)

Offline dvd871

  • Level 21
  • *
  • Posts: 238
  • Reputation: +7/-0
    • View Profile
    • Dominion Siege
New Game Project
« on: October 15, 2006, 10:41:05 PM »
Well, I got a basic html template and made a few mods to it and started a external css styles sheet, made a simple bare minimum database, and a few starting files to build on.  I will post the files that I have here so if anyone want to follow along and see how a few things are done, they can.  The main objective of the project would be simple, very straight forward design, down and dirty, get the job done type of stuff.  You can add the bells and whistles later.

Tools I will be using are:

Easyphp v1.8
the dev sever on local pc - http://www.easyphp.org/telechargements.php3

N-vu
I use this to build tables and forms, but not much else - http://www.nvu.com/download.php

You will also need some kind of text editor or a php ide.  I have used php coder pro in the past and it worked well and is free.  There are lots of different ones so use what you like.
http://www.phpide.com/phpcoder/download.htm

Now that we have a base to work from the things that we will need to do are, and these are in no specific order at this point:

fields for player accounts table
secure login
ingame mail
fields for ingame mail database
admin panel

So many more things, but I don't want to overwhelm anyone so we will just go with that for now, and the admin panel will be a work in progress as we go.

Zip should be attached to this post if all goes well.  Let me know if there is a problem.

Cheers,
Dan

Offline Pug307

  • Level 21
  • *
  • Posts: 244
  • Reputation: +6/-1
    • View Profile
Re: New Game Project
« Reply #1 on: October 15, 2006, 10:53:30 PM »
I am going to be a follower, this might be a gret opportunity for me to learn something useful when it comes to PHP. I will be under your wing all the way.

Keep me updated either on here or via email

Regards


Ant



Offline Pug307

  • Level 21
  • *
  • Posts: 244
  • Reputation: +6/-1
    • View Profile
Re: New Game Project
« Reply #2 on: October 15, 2006, 11:00:00 PM »
Sorry for double posting, Can I just ask what you are basing this game on? I will hopefully be able to create a text based racing game from it but will wait till its complete.




Offline dvd871

  • Level 21
  • *
  • Posts: 238
  • Reputation: +7/-0
    • View Profile
    • Dominion Siege
Re: New Game Project
« Reply #3 on: October 15, 2006, 11:11:39 PM »
I really don't even know right now.  I thought that I would add the normal things that most games have then we could decide what route to take.  Sort of like develope a good base to work from.

Offline Pug307

  • Level 21
  • *
  • Posts: 244
  • Reputation: +6/-1
    • View Profile
Re: New Game Project
« Reply #4 on: October 16, 2006, 10:29:26 AM »
You could always create a hacking game like Cypher. I wouldn't mind running something like that. I am just playing it now. It is slightly confusing but very well setup



Offline codestryke

  • Administrator
  • Level 33
  • *****
  • Posts: 589
  • Reputation: +22/-0
    • View Profile
    • eXtremeCast Games
Re: New Game Project
« Reply #5 on: October 16, 2006, 06:26:39 PM »
You could always create a hacking game like Cypher. I wouldn't mind running something like that. I am just playing it now. It is slightly confusing but very well setup

thanks :) Ya Cypher is a little difficult to pick up at first but once you get the basic concepts down then it's easy and really fun. It's just getting over that first hurdle of understanding nodes, trace time and detection....

As for this project let me just say *FIRST* thing you need to code is a signup/login. Once you have those two items mastered and SECURED then the rest of the game will fall into place. Learning how to use and code sessions is probably the 2nd most important thing you can do in web game design. The first, as you posted in another thread, is how to manipulate, store and retrieve items from a database. I've seen more games go down *NOT* by the PHP programming aspect of it but from the database. The database will always be the Achilles heal, thats why it MUST be mastered. A query will run fine with 10 players online, get 100+ online then it's a whole 'nother story.

Oh, and you can get the genders from a single call to the database, not two...

SELECT COUNT(*) FROM players GROUP BY gender

Not sure what the tables are etc but thats the basic idea of the correct syntax to do it, and if you are going to call that function often then put an index on it.. If you don't really use that but on a few reports then an index isn't necessary.




Creating online addictions, one game at a time:

Offline Pug307

  • Level 21
  • *
  • Posts: 244
  • Reputation: +6/-1
    • View Profile
Re: New Game Project
« Reply #6 on: October 16, 2006, 07:05:34 PM »
The gender code you referred to is something I have already tried. The problem with it is that it counts everything in that row which basically gives me the same number as the total members. I want to be able to call just Male and just Female from the same row



Offline dvd871

  • Level 21
  • *
  • Posts: 238
  • Reputation: +7/-0
    • View Profile
    • Dominion Siege
Re: New Game Project
« Reply #7 on: October 17, 2006, 12:20:29 PM »
I think we should use the old silentstalk code as a starting point since it has a few things done for us already.  The layout is sub-par, but that should be easy to fixup.  The code seems to be ok though.  Not much point in reinventing the wheel for a small project like this.  I think it has a good base to work from.  It was however coded with the idea of register_globals being enabled which most hosts have disabled now because it is a security risk.

Offline compuken

  • Level 10
  • *
  • Posts: 63
  • Reputation: +2/-5
    • View Profile
Re: New Game Project
« Reply #8 on: October 17, 2006, 01:44:07 PM »
A good starting point for the game is a blank file called main.php, that will be your main page in the game.
 From there add a few lines of text to make sure its working (should be since only 1 php file).
Next you create the login/logout/register pages. This is where you start to form the database, think of what information you want the player to have - age,email,username,password, game variables (bullets, energy, weapons), then you build the database and the register page.
This register page should be register.php and be called from index.php which is just a login box, and links to register and forgot password (optional), click on register and you should be taken to register.php. If register.php works you can check your database and be sure that the user is in there and all his variables are filled out correctly.
 Next make the login work, if the user can login to the main.php page then you have done quite a bit and have a good starting spot for adding features.
 I would recomend you have a idea of the game so you can build the game's variables upon regisitering the player.

Offline compuken

  • Level 10
  • *
  • Posts: 63
  • Reputation: +2/-5
    • View Profile
Re: New Game Project
« Reply #9 on: October 17, 2006, 01:51:02 PM »
with the player able to register and login, you can build the parts that show the users logged in, how many registered players there are, and build a simple admin section usually built under /admin folder. It is here you should have the similar setup as the game so far but have the register.php spot have just register a admin for the first time and store this info under a different table in your database, once you have yourself registered, delete the new register.php or disable the code so no one else can register as a admin. Now under your main.php page in the /admin section you can setup to see all users info, all users ip, be able to blocker ip, usernames, email, etc. You should create a spot to see if anyone tried logging into your /admin/index.php spot. That should be a great starting spot, you can if you wanted to remove all game related variables in the register.php spot in the game register.php if you just want to have a basic game skeleton.

Offline dvd871

  • Level 21
  • *
  • Posts: 238
  • Reputation: +7/-0
    • View Profile
    • Dominion Siege
Re: New Game Project
« Reply #10 on: October 17, 2006, 09:34:32 PM »
Anyone that wants to get in on a project like this should send me a PM.

Offline dvd871

  • Level 21
  • *
  • Posts: 238
  • Reputation: +7/-0
    • View Profile
    • Dominion Siege
Re: New Game Project - update 001
« Reply #11 on: October 18, 2006, 10:34:56 PM »
Ok, scrap the silent stalk code, its too old and needs to much work.  I've went ahead with what I origianlly started.  So far this is what we have:

A rough template, functional, but still LOTS of room for improvement
signup script - 100% complete
account activation - 100% complete
login script - 100% complete
generic main area
logout script - 100% complete

If you want to see the project live you can look here: http://dev.medievalempires.org/
I setup a subdomain on one of my hosts and will keep the live project there.

New files are posted below.  You must delete the old files and extract the new ones from this zip.
Also the database has changed.  Drop the old tables and import the new sql file.

All code and template files have been created by me so there is now worries about any copyright issues.  I release this code as is and without warranty.  I am not liable if it somehow formats your pc then goes on a rampage and destroys something.  Use the code at your own risk.  You have been warned! - legal BS that must be posted, you know the deal.   ;)

Game update zip files will be numbered as game_xxx.zip where xxx is the number of the update.
Most recent update is 001.

At some point soon we will need ideas for gameplay elements so hopefully a few of you creative peeps will post some thoughts.

Cheers!  ;D

Offline Shapulin

  • Level 9
  • *
  • Posts: 50
  • Reputation: +2/-4
    • View Profile
Re: New Game Project
« Reply #12 on: October 20, 2006, 07:55:28 AM »
Hey...I wanna try that...

could help me with my ideas about wbgames...

do you have some data model???


Offline Cripple

  • Level 17
  • *
  • Posts: 170
  • Reputation: +10/-4
    • View Profile
Re: New Game Project
« Reply #13 on: October 20, 2006, 09:12:34 AM »
i reckon i could throw some graphix in there 4 u dvd.
up to u.

Offline Pug307

  • Level 21
  • *
  • Posts: 244
  • Reputation: +6/-1
    • View Profile
Re: New Game Project
« Reply #14 on: October 20, 2006, 10:50:19 AM »
No point in creating any graphis yet mate until DVD know's what type of game he will be creating. I will also help out with the graphic side of things if needed. I have 2 years self experience with photoshop so not too bad with it.

I would also like to say DVD, when we were trying to sort out the layout for my pimp game and I was having problems. I managed to figure it and the layout is coming on nicely. Thanks for the help. I just needed to read some table tuts to help me and touchwood it worked lol



Offline codestryke

  • Administrator
  • Level 33
  • *****
  • Posts: 589
  • Reputation: +22/-0
    • View Profile
    • eXtremeCast Games
Re: New Game Project
« Reply #15 on: October 21, 2006, 11:17:21 AM »
Very nice start... Couple suggestions....

* The login and account creation is susceptible to a SQL injection attack. Using the standard trim(stripslashes()) is good but not bullet proof. The attacker can still use ; to terminate and start another query, or they can use a , and insert another variable. Best bet is to create a regex expression to only allow safe characters.

* Since this is a game and will basically be making calls to the random number generator on a LOT of pages ya might as well just put the srand((double)microtime()*1000000) in the config file. Might want to switch it to mt_srand also (read php docs as to why).

* Notice how you are continually calling the SQL server to bring back a single piece of data?  A nice function to add and use would be something like:

Code: [Select]
function db_getone($sql) {
  global $db_q;

  $db_q['queries']++;
  $r = mysql_fetch_array(mysql_query($sql));
 
  return($r[0]);
}

So in your signup page you could do:
Code: [Select]

  $check_email = db_getone("SELECT COUNT(*) FROM accounts WHERE email='$email'");
  $check_username = db_getone("SELECT COUNT(*) FROM accounts WHERE username='$username'");
 
  if( ($check_email > 0) || ($check_username > 0) ){
    $err.="Please fix the following errors: <br />";
    if( $check_email <> 0 ){
    $err.="Your email address has already been used by another member. Please submit a different Email address!<br />";
    }
    if( $check_username <> 0 ){
      $err.="The username you have selected has already been used by another member. Please choose a different Username!<br />";
    }
  }

Same functionality, just a bit cleaner.

-------------------------------------------------------

NOTE, the following are suggestions you can take or not take. These are suggestion based on past experiences I've had with running and writing games.

Better directory structure. A LOT of games I notice place the whole game in the root directory and only use sub-directories for images etc etc.. The problem I had in the past was what if you wanted to shut the game down yet keep the front-end portal open. I've had to do this many times to fix bugs or exploits and basically couldn't (well could but not without a HUGE amount of effort).

What I do now for all my games is place the front end in the root and the actual game itself in a directory called main. If I need to block all the players from getting into the actual game I just drop a .htaccess file into the main directory and wha-la everyone is blocked but me ;)

Here is a sample of how I lay things out:
Code: [Select]
Root Dir
  main
  includes
  admin
  images
 
 
Next thing is ask yourself is this going to be the only game you will ever create? How many times do you want to write the same thing over and over and over again? You have a nice template here but if you wanted to create another game off of it yet change stuff around you would have to edit a lot of pages. Why not start breaking items up, now, so in the future you have pre-built libs you can use right away ;)

Create a file called accounts.lib.php  In this file are the functions to:
* Create an account
* Delete an account
* Activate account
* Send account password
* Reset an account

Now you have 1 file you can go to when you want to change things, plus everything is outlined that you already need to setup for the next game.

--------------------------------------------------------

Like I said great start.. Didn't get time to put the db on my system to check the table layouts but hopefully soon I will be able to...


Creating online addictions, one game at a time:

Offline Zeggy

  • Global Moderator
  • Level 35
  • *****
  • Posts: 1,187
  • Reputation: +13/-4
    • View Profile
Re: New Game Project
« Reply #16 on: October 21, 2006, 11:29:24 AM »
Nice tips codestryke :)

What is going to go in the 'main' folder then?
Wouldn't most of the main game files be in the root folder anyways?

Offline dvd871

  • Level 21
  • *
  • Posts: 238
  • Reputation: +7/-0
    • View Profile
    • Dominion Siege
Re: New Game Project
« Reply #17 on: October 21, 2006, 03:15:12 PM »
Good idea about the db_getone function.  I had thought of that before just never did it.  Its easy to fall into the habits of our old ways when coding something.

I don't worry too much about the sub-directories.  What I do is create a table in the database called system and place some options in there for site control.  Usually something like, allow_logins, allow_signup, etc.  That way I can control signups and the opening and closing of the site from the admin panel, and then its a simple query during login to check options.

SQL injection in forms are always a problem.  I have used the reg_ex method in the past as well as the mysql_escape_string function.  I seem to remember that I wrote an anti-injection function sometime ago.  I will look and see if I can find it.

Thanks for the tips.  I really should add a few of the things you mentioned to my standard coding, specially the creation of lib files for account creation, validation, etc.

Offline codestryke

  • Administrator
  • Level 33
  • *****
  • Posts: 589
  • Reputation: +22/-0
    • View Profile
    • eXtremeCast Games
Re: New Game Project
« Reply #18 on: October 21, 2006, 05:54:40 PM »
Nice tips codestryke :)

What is going to go in the 'main' folder then?
Wouldn't most of the main game files be in the root folder anyways?

The actual game itself, the root directory would only contain the front end pages like, index/login, signup, activation etc.

Creating online addictions, one game at a time:

Offline codestryke

  • Administrator
  • Level 33
  • *****
  • Posts: 589
  • Reputation: +22/-0
    • View Profile
    • eXtremeCast Games
Re: New Game Project
« Reply #19 on: October 21, 2006, 05:58:23 PM »
I don't worry too much about the sub-directories.  What I do is create a table in the database called system and place some options in there for site control.  Usually something like, allow_logins, allow_signup, etc.  That way I can control signups and the opening and closing of the site from the admin panel, and then its a simple query during login to check options.

Then your doing a query on each page just to get the status of the game. Did that myself for a while then I got 3000 players with 100-200 online at one time and the server started to lag very quickly with that type of activity.

Truth be told I would like to see a switch to ADODB for this project. Trust me only you start using it you'll start kicking yourself for not using it in the pass as it makes DB access so much easier and portable.

If I get the time I will add some stuff to the project...

Creating online addictions, one game at a time:

Offline Zeggy

  • Global Moderator
  • Level 35
  • *****
  • Posts: 1,187
  • Reputation: +13/-4
    • View Profile
Re: New Game Project
« Reply #20 on: October 21, 2006, 06:04:53 PM »
Yep, adodb is awesome once you get to learn it :)
It's made it a lot easier for me to code. Plus, it looks nicer :P

Offline codestryke

  • Administrator
  • Level 33
  • *****
  • Posts: 589
  • Reputation: +22/-0
    • View Profile
    • eXtremeCast Games
Re: New Game Project
« Reply #21 on: October 22, 2006, 06:59:56 AM »
Here it is community project major update :)

* Switched to ADODB
* Added page header/footer
* Secured create/login pages
* Moved all account actions to account.lib.php
* Defined directory structure

The database I changed the date columns you had to datetime stamps, using a varchar for date/times will NOT sort properly. Added unique index to user name and added a index to status.

The archive is a bit big because I included the whole ADODB library, you only really need to have 4 files out of this lib though...

Use it or don't, it's a good solid start for any new project ;)

Enjoy :)

http://www.extremecast.com/game_002.zip
Creating online addictions, one game at a time:

Offline dvd871

  • Level 21
  • *
  • Posts: 238
  • Reputation: +7/-0
    • View Profile
    • Dominion Siege
Re: New Game Project
« Reply #22 on: October 22, 2006, 01:13:43 PM »
Here it is community project major update :)

* Switched to ADODB
* Added page header/footer
* Secured create/login pages
* Moved all account actions to account.lib.php
* Defined directory structure

The database I changed the date columns you had to datetime stamps, using a varchar for date/times will NOT sort properly. Added unique index to user name and added a index to status.

The archive is a bit big because I included the whole ADODB library, you only really need to have 4 files out of this lib though...

Use it or don't, it's a good solid start for any new project ;)

Enjoy :)

http://www.extremecast.com/game_002.zip

Looks very nice indeed.  I always say that I'm going to use AdoDb and then I slack and don't do it.  From now on I am just going to force myself to use it and then it will become part of my regular practise.  Its not much diiferent other than knowing what the function names are so why not use it :)

The account.lib.php look sweet!  Too bad I'm not that organized, lol!  I have scraps of code fragments that I've been working from for years. Bad habit of copy and paste! :)   I should get them organized better into functions like you have done.

Nice work.  We'll consider this the latest version and continue from there then.

Offline codestryke

  • Administrator
  • Level 33
  • *****
  • Posts: 589
  • Reputation: +22/-0
    • View Profile
    • eXtremeCast Games
Re: New Game Project
« Reply #23 on: October 22, 2006, 07:42:15 PM »
Hey I'm the same way, I've got scrap code ALL OVER. Most of my games online are still suffering from code "all over", I always tend to get back and rewrite it cleanly but I never do (if it works don't touch it!).

The last game release and the two others I'm working on actually use the "clean" account.lib.php code because I was sick of writing the same functions over and over and over for all the games :) Programmers *ARE LAZY* oh we'll code to the midnight hours when it's cool new shit, stuff we've done a million times pfft forget it LOL...

Glad ya liked the code, now has there been any discussion on where to take the game next, do we have a or theme? Lets face it the pimp thing is played out, mafia is getting real close to getting played out and I've never been one for space trading games (though I keep pondering trying Eve LOL).
Creating online addictions, one game at a time:

Offline Zeggy

  • Global Moderator
  • Level 35
  • *****
  • Posts: 1,187
  • Reputation: +13/-4
    • View Profile
Re: New Game Project
« Reply #24 on: October 23, 2006, 12:31:40 PM »
Heh, I agree with codestryke... I am so lazy and unmotivated... When I am starting something new, it goes really fast because I'm really enthousiastic, but after a few days... development practically stops XD
It might take weeks or months before I get back to it. I guess it's because the project becomes so boring.
An example is my current game, http://www.zegghq.com
I can't bother expanding the game because there's not much challenge anymore, just a waste of time. :(


I really gotta stop this XD

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal