Web Based Game Essentials

Looking to make a game? Then this is a must read

  • (2 Pages)
  • +
  • 1
  • 2

22 Replies - 30917 Views - Last Post: 22 September 2013 - 12:48 AM Rate Topic: ***** 8 Votes

#16 aaron1178  Icon User is offline

  • Dovakiin, Dragonborn
  • member icon

Reputation: 169
  • View blog
  • Posts: 1,297
  • Joined: 22-October 08

Re: Web Based Game Essentials

Posted 05 October 2010 - 02:39 AM

Hey great post, as a developer are always looking for new ways to improve my code, and after reading this, its made my day a hole lot easier Thanks.
Also as i love 3D i just want to say this! You can use programs like blender or Maya( which i found really good foe cinematics) to create cinematics for your game, just like the trailers for games or the little pre movies before you start e.g on assasins creed 2
Was This Post Helpful? 0
  • +
  • -

#17 n_yanev  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 35
  • Joined: 24-October 10

Re: Web Based Game Essentials

Posted 16 November 2010 - 12:49 PM

This article was very useful for me. Thank you man.
Was This Post Helpful? 0
  • +
  • -

#18 richmund12  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 38
  • Joined: 10-October 09

Re: Web Based Game Essentials

Posted 27 May 2011 - 03:25 PM

I think I'll try and get started. :)

Thank you JB. :)
Was This Post Helpful? 1
  • +
  • -

#19 JDKeller  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 17
  • Joined: 13-May 10

Re: Web Based Game Essentials

Posted 28 June 2012 - 07:52 PM

I want to address the issue of cron jobs on a server. If you are running a Linux environment or using a web host like Amazon, there is support for cronning tasks, however with Yahoo, there is no option. Here is how I do it using the UNIX timestamp and simple math.

This is a function used to update energy based on time.
function updateEnergy($userid){
 	// setup your db conection

	$lastUpdatedQuery = sprintf("SELECT last_updated FROM energy WHERE userid = '%s'",
		mysql_real_escape_string($userid));
        // last_updated is stored as an integer based on UNIX_Timestamp
	$lastUpdatedResult = mysql_query($lastUpdatedQuery);
    $lastUpdatedRow = mysql_fetch_row($lastUpdatedResult);
	$lastUpdated = $lastUpdatedRow[0];
	$getCurrentEnergyQuery = sprintf("SELECT energy FROM energy WHERE userid = '%s'",
		mysql_real_escape_string($userid));
	$getCurrentEnergyResult = mysql_query($getCurrentEnergyQuery);
    $getCurrentEnergyRow = mysql_fetch_row($getCurrentEnergyResult);
	$currentEnergy = $getCurrentEnergyRow[0];
	
	$ticks = (time() - $lastUpdated);
        // In PHP, time() returns the current time in seconds since the epoch.
	// Ticks are the amount of time that has passed since the last update in seconds.
	if ($ticks > 3600) {
        // 3600 seconds = 1 hour
		if (intval($currentEnergy) >= 10){
                // Since 10 is the maximum energy value, this just sets the update time to when it should have last updated.
			$newUpdate = ($lastUpdated + (intval($ticks / 3600)*3600));
			//mysql_query($updateEnergyQuery);
			$updateLastUpdatedQuery = sprintf("UPDATE energy SET last_updated = " . $newUpdate . " WHERE userid = '%s'",
				mysql_real_escape_string($userid));
			mysql_query($updateLastUpdatedQuery);
		} else {
			$intNumberOfUpdates = (intval($ticks / 3600) + $currentEnergy);
				if ($intNumberOfUpdates > 10) {
					$updateEnergyQuery = sprintf("UPDATE energy SET energy = '10' WHERE userid = '%s'",
						mysql_real_escape_string($userid));
					mysql_query($updateEnergyQuery);
				} else {
					// how many times to update the table, or how much energy to update the table with.
					$newUpdate = ($lastUpdated + (intval($ticks / 3600)*3600));
					$updateEnergyQuery = sprintf("UPDATE energy SET energy = " . $intNumberOfUpdates . " WHERE userid = '%s'",
						mysql_real_escape_string($userid));
					mysql_query($updateEnergyQuery);
				}
			$updateLastUpdatedQuery = sprintf("UPDATE energy SET last_updated = " . $newUpdate . " WHERE userid = '%s'",
				mysql_real_escape_string($userid));
			mysql_query($updateLastUpdatedQuery);		
			}
		
	} else {
		// do nothing ...
	}
}


What this does is update the table for energy value and last_updated time so that there will be a consistent record. I am sure this is lacking, but this is a good start.
Was This Post Helpful? 0
  • +
  • -

#20 WotCGM  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 16-November 12

Re: Web Based Game Essentials

Posted 16 November 2012 - 02:30 PM

This tutorial was over 2 years old when I found it today.
And you know what? It is still just a useful as the day
it was 1st written.

The over-view of game development was very well written and
both fun and easy to read.

Kudos!!

Larry
Was This Post Helpful? 0
  • +
  • -

#21 mintzkie009  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 07-July 12

Re: Web Based Game Essentials

Posted 05 December 2012 - 03:07 AM

Nice tutorial. I liked to ask if PHP can be used in programming the graphics on HTML5 Canvas? All I know for now is than Javascript is the language used in HTML5 Canvas. Can PHP do the same thing as Javascript did in HTML5 Canvas?
Was This Post Helpful? 0
  • +
  • -

#22 annaharris  Icon User is offline

  • New D.I.C Head

Reputation: -4
  • View blog
  • Posts: 38
  • Joined: 03-May 12

Re: Web Based Game Essentials

Posted 01 April 2013 - 06:08 AM

This information was really fruitful. Anyone who is interested in developing a game should read this as it provides all the fundamental details for game development.
Was This Post Helpful? 0
  • +
  • -

#23 DauntlessRob  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 30
  • Joined: 22-September 13

Re: Web Based Game Essentials

Posted 22 September 2013 - 12:48 AM

I just wanted to jump in and say thank you for this tutorial. Most of it was pretty obvious already to me, but what was so useful to me was that it was encouraging.

I'm not a great programmer, and I've undertaken the huge task of building an online game so that I can sharpen my programming skills. So since your tutorial made me feel welcome to this forum, I joined! Thank you!
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2