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

November 22, 2007

Get Page Name from Web Address using PHP

Filed under: PHP — admin @ 12:55 pm

This syntax is useful for dynamically creating web pages. For example with PHP you can recognize the page you are on and then display a proper header for that page.

i.e. let’s say the weblink is “www.page.com/form.php”

$page_name =  basename($_SERVER['PHP_SELF'],".php");

The “$page_name” would equal “form” for the .php was dropped.

Capitalize the First Letters in a String with PHP

Filed under: PHP — admin @ 12:48 pm

This is a useful syntax just another one that just slips my mind.

$string = 'john doe';
$new_string = ucwords($string);
echo $new_string; //John Doe

Character Replace within a String using PHP

Filed under: PHP — admin @ 12:45 pm

Replacing a character within a string is easy and very useful. The only problem is I have the hardest time remembering the syntax so I figured I would post it here.

$string = 'test-data';
 
//Remove the "-" and replace it with a space
$new_string = str_replace('-',' ', $string );
 
echo $new_string; //test data

November 21, 2007

Looping with PHP to Build a Table

Filed under: PHP — admin @ 12:00 pm

Looping comes in handy when you may want to execute a certain script “x” number of times or if you want to display all the information within a Recordset. Here is an example of how I display all the information stored within a Recordset into a nice table that is easy to read.

<!-- setting up the table -->
 
<table border=”1″>
<tr>
<td>First Name</td>
<td>Last Name</td>
<td>Id</td>
</tr>
 
<?php //create the loop
 
do { ?>
 
<tr>
<td><?php echo $row_Recordset1['first_name']; ?></td>
<td><?php echo $row_Recordset1['last_name']; ?></td>
<td><?php echo $row_Recordset1['id']; ?></td>
</tr>
 
<?php //end the loop
 
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>

This will display all the information for Recordset1 within a table with the heading cells being First Name, Last Name, and ID. Recordset1 must first be established before you will be able to populate the cells or else no data is found.

November 20, 2007

PHP Recordsets

Filed under: PHP — admin @ 8:07 pm

Recordsets in PHP are useful bits of code used to display data that is stored within a MYSQL table. You can run a loop to display all of this data or you can display only the bit of information you want. Here is how I do this:

<?php
//First Connect to the Database
 
$hostname_connect = "localhost";
$database_connect = "db_name";
$username_connect = "db_user";
$password_connect = "db_password";
$connect = mysql_connect($hostname_connect, $username_connect, $password_connect) or trigger_error(mysql_error(),E_USER_ERROR);
 
//Create the Recordset and grab the data you want
 
mysql_select_db($database_connect, $connect);
$query_Recordset1 = sprintf("SELECT * FROM names WHERE name='steve'");
$Recordset1 = mysql_query($query_Recordset1, $connect) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
 
?>
 
<!–Display the data within the page –>
<body>
 
<p>Hello <?php echo $row_Recordset1['name']; ?>, you live on <?php echo $row_Recordset1['street']; ?>. You have <?php echo $row_Recordset1['kids'] ?> kids.</p>
 
</body>
 
<?php
 
//Close the Recordset and Connection
 
mysql_free_result($Recordset1);
mysql_close($connect);

The above example grabbed data from the MYSQL table “names” only where the row’s name was “Steve”. Then data is displayed about Steve in each of the rows within the table; such as address and kids.

Map Travel

Filed under: DE Games — admin @ 7:47 pm

I have finished the map travel coding. Now a character will be able to explore a 5×5 grid moving in the cardinal directions. The character is represented as a red dot. I will add chance for random fights for every movement. Each map will have its own paths to the next area; as well as its own unique enemies that you will face.

November 10, 2007

Attribute System

Filed under: DE Games — admin @ 8:26 am

The attribute system is now up and functioning. Within the game you will have the ability to control the fields that your character will excel in. Each category will allow you to put 10 points into it. Each point you put in increases your stats for that attribute, but like all games, the higher the point value the more attribute points it will take to move to the next point level.

Currently the levels are set at:

  • Level 1 – 1 point
  • Level 2 – 2 points
  • Level 3 – 4 points
  • Level 4 – 8 points
  • Level 5 – 16 points
  • Level 6 – 32 points
  • Level 7 – 64 points
  • Level 8 – 128 points
  • Level 9 – 256 points
  • Level 10 -  512 points

November 6, 2007

The New Project…

Filed under: DE Games — admin @ 7:45 pm

Ah, the flesh and blood of what I stand for… gaming. I will create games and so far the only way I know how is with PHP. With the know how I decided it will be done!

The project:

I am going to create a basic online text based game where a player can create a character and give it a name and profile. They will then be able to take this player though the world of Asairion battling creatures, gaining items, levels, weapons, and armor along the way.

The players stats will be fully customizable and will allow the player – at any time – to adjust their character to how they see fit. Some of the categories that the player will be able to enhance are:

  • Attack: The general attack of the character
    • Can be improved upon by weapons
    • Can be disabled by spells
  • Defense: The general defense of the character
    • Can be improved with shields and armor
    • Can also be “broken” to provide some but not full protection
  • Agility: The quickness of the character
    • Affects weather the character or enemy will attack first
    • With higher agility the easier it will be to dodge attacks
    • Can be improved with weapons and armor or spells
    • Can be reduced by spells
  • Accuracy: The ability to hit with a weapon
    • This is also affected positively or negatively by items or spells
  • Magic: This will affect the power of the hero’s spells
    • Use elements against other elements
      • Fire vs. Water will be weak
      • Fire vs. Fire will be normal
      • Fire vs. Earth will be strong
  • Magic Defense: This affects how well you can withstand magic spells
    • Affected by armor and shields and spells

I will add more to this with what I have completed in the game and what I am working on. I have started this blog a little late so I will catch up to what I have completed thus far.

So far I have created:

  • A basic attack for the character
    • If the character chooses to attack, the damage is based on his attack and the weapon that he has equipped. The character has a max and min damage and the amount of damage done is generated randomly in between those two numbers.
    • The attack damage is then applied to the enemy subtracting the enemies armor.
    • For this attack the character will have a slim chance to miss, the less chance he will have to miss the higher his accuracy is. It will also depend on the enemies agility.
  • Enemy Retaliation
    • Of coarse with every action there is an equal and opposite reaction. The enemy WILL retaliate (unless you killed it).
    • The enemy will have a 50/50 chance of attacking with magic or his standard attack.
    • If you couldn’t guess, programming the magic was a bitch!
      • The enemy will cycle through his skills determining if the magic slot is full or empty and if the enemy has enough mana then it will randomly cast one of the active spells.
  • Death to the enemy or hero!
    • Yes, you can die. If you do die you will be returned to the last town you left missing some of your gold.
    • If you are victorious in battle you will receive experience, riches, and possible a common, uncommon, or rare item
  • Inventory
    • To gain these items I gave the hero an inventory in which the character can stack items he has acquired in 20 different slots.

More will come with time. Right now I can only work on this game during my 30 minuet lunch break and on and off before school.

I will post more as it becomes available.

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