Blog

Newest Post
Blog Archives
Blog Categories

Portfolio

3D Models
Banners
Brochures
Business Cards
Custom Programming
Environments
Flash Projects
Game Design
Image Altering
Web Design

About

Resume
Recommendation Letters

Contact

May 23, 2008

PHP Dynamic Variables

Filed under: PHP,The Coding World — admin @ 9:21 am

Let’s say that you have a bunch of data in a recordset and you want to populate that data into a list of variables. In my example we will draw 20 items from a players inventory from a MySQL table which stores all the items for a player in rows we call “slot_1, slot_2, slot_3, … all the way to 20″. So when we pull all of the items from the MySQL table we want to assign them to variables respectively. For example, our variable of “slot_1″ that we are creating will equal “slot_1″ from the MySQL table.

//the recordset
 
mysql_select_db($database_connect, $connect);
$query_Recordset1 = sprintf("SELECT * FROM inventory WHERE player_id='$hero_id'");
$Recordset1 = mysql_query($query_Recordset1, $connect) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
 
//Loop and assign the variables accordingly
 
$i=1; do {
${"slot_{$i}"} = $row_Recordset1['slot_'.$i];
$i++;} while ($i<=20);

If we were to update the MySQL table with a dynamic variable, it would look like this.

 
$updateItemSQL = sprintf("UPDATE inventory SET slot_$slot=%s WHERE player_id='$hero_id'",
GetSQLValueString($new_item, "int"));

Merchant System and Guard Ability

Filed under: DE Games — admin @ 9:10 am

I have added a Merchant System and Guard Ability to the game now. The player can now purchase and sell items. If they player tries to sell a weapon, shield, magic, or armor that is the only one left in their inventory – a warning message will appear letting them know if they sell it it will be unequipped and removed from inventory.  This prevents the player from accidentally selling an item they have equipped.

The player will also have the option of buying any common weapons, shields, armors, or magics in the game. If they do not have enough money or if all their inventory is full the player is notified.

A guard option is now available in battle in case the players other commands are rendered useless. In example, if the player has no mana to cast a spell and their attackhas been rendered useless by a spell. The player can guard to boost their armor by 33% for that turn.

May 16, 2008

Update to Dragon Seed

Filed under: DE Games — admin @ 1:49 pm

Well it has been awhile since I updated the blog with how the PHP scripted game is coming along. Since my last post I have created a Ladder system based on experience earned by the character.

Player status! Yes, the player can now check on their status. You can view their current health and mana, equipped magic, and even see their attack dmg, defense, agility, and accuracy. This page will eventually serve as a profile page for each character.

Equip page. Players can now equip magics they have acquired by equipping the orbs. They can also equip different weapons, armors, and shields.

Inventory. Inventory has been created and players can view all the items they are carrying. They can also use select items such as mana potions and health potions.

Magic rollovers. You can now roll over magic spells to view their mana cost, dmg, and description.

A beta version will be available to test soon!

© - Digital Epiphany Designs, Online Portfolio for Web Design, Custom Programming, Grapic Design and Game Design.