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
Web Based Game EssentialsLooking to make a game? Then this is a must read
21 Replies - 23939 Views - Last Post: 01 April 2013 - 06:08 AM
#17
Re: Web Based Game Essentials
Posted 16 November 2010 - 12:49 PM
This article was very useful for me. Thank you man.
#18
Re: Web Based Game Essentials
Posted 27 May 2011 - 03:25 PM
I think I'll try and get started. 
Thank you JB.
Thank you JB.
#19
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.
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.
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.
#20
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
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
#21
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?
#22
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.
|
|

New Topic/Question
Reply





MultiQuote




|