Type Casting in ASP

ASP No Comments

Turns out you have to use the VB functions….

Asc - Converts the first letter in a string to ANSI code
CBool - Converts an expression to a variant of subtype Boolean
CByte - Converts an expression to a variant of subtype Byte
CCur - Converts an expression to a variant of subtype Currency
CDate - Converts a valid date and time expression to the variant of subtype Date
CDbl - Converts an expression to a variant of subtype Double
Chr - Converts the specified ANSI code to a character
CInt - Converts an expression to a variant of subtype Integer
CLng - Converts an expression to a variant of subtype Long
CSng - Converts an expression to a variant of subtype Single
CStr - Converts an expression to a variant of subtype String
Hex - Returns the hexadecimal value of a specified number
Oct - Returns the octal value of a specified number

http://www.w3schools.com/vbscript/vbscript_ref_functions.asp 

Vancouver International Game Summit features Call of Duty 4, May 21- 22

Conferences, Game Developement, News No Comments

http://www.rebootconference.com/games2008/

 

Title Sponsor - Electronic Arts

The agenda is now finalized and this is one Game Summit you don’t want to miss!

The Vancouver International Game Summit and its Advisory Board are pleased to announce that this year’s closing keynote event will feature the key leaders behind the 2007 Game of the Year: Call of Duty® 4: Modern Warfare™.

“Call of Duty® 4: Modern Warfare™ - The Business and Game Design behind the 2007 Game of the Year” - “A talk with Tabitha Hayes, & Vince Zampella on the success of Call of Duty® 4: Modern Warfare™. How Business, Brands and Exceptional Game Design come together for a blockbuster hit.”

The purpose of this panel is to explore and expand on the powerful partnership and tremendous success that can be had when marketing, brand management, a long term vision and exceptional game design come together. This is a moderated panel. Questions will be pre-screened, submit to: http://www.vancouvergamesummit.com/blog/

Other highlights at this year’s Summit include opening keynote speakers Shane Kim, Corporate Vice President, Microsoft Games Studio, and Jason Rubin, founder and former President of Naughty Dog.

WHEN: May 21-22, 2008
WHERE: Hyatt Regency, Vancouver, British Columbia
ON-LINE REGISTRATION: http://www.vancouvergamesummit.com

CONFERENCE TOPICS

  • Untapped Markets, Who are the Customers?
  • New Business Models for the Next Decade
  • Fostering the Leaders of Tomorrow
  • New Frontiers in Animation
  • Outsourcing Concepts
  • International Markets - What are the Opportunities, What are the Challenges?
  • Audio Production
  • Advanced Techniques from the Animation Industry
  • Adapting your Pipeline to Multi Technology Platforms
  • The Story and Focus Narrative
  • Low-Fi Prototyping
  • “Going Green” and how that applies to the Video Games Industry

Click here for the full agenda and confirmed conference speakers: http://www.vancouvergamesummit.com/agenda2008.php

ACCOMMODATION

The Hyatt Regency, Vancouver
The hotel is offering a special conference delegate rate of $219 per night.
Please contact the Hyatt directly using this special Games delegate link: https://resweb.passkey.com/go/ed5f5c22

655 Burrard Street,
Vancouver, British Columbia, Canada V6C 2R7
Tel: +1 604 683 1234 Fax: +1 604 689 3707
Web Site: http://www.vancouver.hyatt.com

For full conference information and registration, please visit our website at: http://www.vancouvergamesummit.com/

We invite you to pass this message on to interested colleagues and look forward to seeing you in Vancouver this May.

Gregory Spievak
Conference Chairman
250-388-6060
250-881-4045
spievak@rebootconference.com
Kenton Low
Advisory Board Co-Chair
President, New Media BC
Howard Donaldson
Advisory Board Co-Chair
VP, Studio Operations
Propaganda Games

Learning PHP (Part 3)

PHP & MySQL, Programming, Snippets, Tutorials No Comments

In part 2 I covered else-if statements and more complicated if statements. One of the other concepts that’s essential to learning any kind of programming is loops. There are three different types of loops (while loop, for loop, and do while loop), but I’m only going to cover two of them here.

While Loops

The concepts of loops is extremely simple. While some condition is true you’re going to run the same bit of code again and again and again until the condition is no longer true anymore. Right away you can probably see the problem with loops: if the condition never becomes false then the loop with go on endlessly. This is called an infinite loop. Infinite loops should be avoided, they eat up your computer’s resources and can even crash your computer completely. In PHP the worst that will happen is that your browser gets a timeout error or crashes. Not the end of the world, but annoying at the same time.

Usually when I explain this example to people I introduce them to Polly, the brightly colored parrot that looooves to repeat everything you say. So, let’s pretend that we walk up to Polly’s cage with a cracker in our hand. Polly, once she sees a cracker, won’t stop begging for one until you give it to her.

<?php

$treat = “cracker”;

while ($treat = “cracker”)
{

echo “Polly want’s a cracker!<br>”;

$treat = “none”; //you give Polly the cracker after she asked for it so now you don’t have a treat anymore

} //once a loop reaches this part it goes back to the beginning and runs the code inside of these brackets all over again

?>

Run this code and see what it does. Polly asks for the cracker, and because you have a fondness for Polly you decide to give it to her. Now lets say you walk up with 5 crackers. Polly seems them and starts begging again.

<?php

$crackers = 5;

while ($crackers > 0) //as long as you have a cracker
{
echo “Polly wants a cracker!<br>”;

$crackers–; //you give Polly a cracker, so the number of crackers you have goes down by one
}

?>

Now run the script and see what happens. Suddenly Polly is asking you for crackers more then once. In fact, she asks you for a cracker 5 times until you don’t have any more crackers left.

What happens if you take out $crackers–;? Would Polly still ask you for crackers? How many times will she ask you?

The syntax for a loop is really simple. As long as the condition inside of it is true, the loop will go through. Now look at some of these examples –NONE of them work correctly. Can you figure out why?

<?php

$crackers = 0;

while ($crackers > 0)
{
echo “Polly wants a cracker!<br>”;
$crackers–;
}

?>

In this case, Polly won’t ask for a cracker because you don’t have any.

<?php

$crackers = 4;

while ($crackers > 5)
{
echo “Polly wants a cracker!<br>”;
$crackers–;
}
?>

In this case, Polly won’t ask you for a cracker because you don’t have more then 5 of them.

<?php

$crackers = 5;

while ($crackers > 0)
{
echo “Polly wants a cracker!<br>”;
$crackers++;
}
?>

In this case, Polly will ask for a cracker forever because each time she asks, you suddenly end up with another cracker out of thin air! See how it says $cracker++? That means increase the number of crackers you have by one each time.

<?php

$crackers = 3;

while ($crackers > 0)
{
echo “Polly wants a cracker!<br>”;
}
?>

Can you sport the problem with this one? This will be an infinite loop because you always have 5 crackers and they never decrease as Polly asks for one.

Now, just because this loop looks really simple doesn’t mean loops can’t have other things php syntax inside of them. Take this for example:

<?php

$crackers = 5;

$mood = “friendly”;

while ($crackers > 0)
{
echo “Polly wants a cracker!<br>”;

if ($mood == “friendly”) //you’re in a good mood today
{
$crackers–; //you give Polly a cracker
}
else
{
echo “Sorry Polly, no crackers for you today!”;
$crackers = 0; //you eat all your crackers yourself
}

}
?>

In this case you only give Polly your crackers if you’re in a friendly mood. Try it out and see what happens when your mood changes.

Programming Challenge! Lets say one day you walk up to Polly and you have 5 crackers. You’re in a good mood so you decide to give her one. Unfortunately Polly isn’t in such a good mood and she bites your finger after the first cracker you give her. Once that happens your mood changes to angry and you eat 2 of the crackers yourself. But Polly is persistent and after a change of heart you give her the remaining 2 crackers. Can you write a while loop to reflect this?

For Loops

Another type of loop is called a for loop. Usually you use a for loop when you have a set amount of times you want to repeat a portion of code. For instance, lets say you run a pet shop and you know you have 23 cages needing cleaning every day. In this case we know you’ll always have to clean a cage 23 times. These are the cases where its appropriate to use a for loop. When you’re uncertain how often you’ll need to repeat a portion of code its more appropriate to use a while loop. Now lets take a look:

<?php

for ($cleancages= 1; $cleancages < 23; $cleancages++)
{
echo “I cleaned cage number $cleancages<br>”;
}

?>

Try running this script. You’ll see that you cleaned cages 1-23. A for loop works exactly like a while loop with a little difference.

$cleancages = 1;

The variable above, at the beginning of the for loop, sets $cleancages to equal one.

$cleancages < 23

Here the for loop checks to see if the number of clean cages is less then 23. As soon as clean cages goes to 24 the for loop stops, because there are only 23 cages and 24 is greater then 23. This part of the for loop is exactly the same as what you would put inside of a while loop.

$cleancages++

One thing to notice is that there is NO SEMICOLON at the end of this. That is how the for loop knows you want to loop for a certain number of times. This part of the for loop is the same as when we were doing $crackers++; or $crackers–; It tells the for loop that ever time it runs it should increase the variable $cleancages by a value of 1.

So, there you have it. Think you can do this?

Programming Challenge! Write a script that has two variables, $forloop and $whileloop. Make it so that if there is a value in the $forloop variable that the script will run a for loop to clean a number of cages. However, if there is a value in the $whileloop variable the script should run a while loop to clean the cages instead. Once you have that done, see if you can make it so the script will run both a for loop and a while loop if there is a value in either of the two variables.

Learning ASP

ASP No Comments

Well, it looks like I’m resigned to learning several new languages if I’m going to program in them for the next several years. So I figured out how to turn on the IIS in Windows Vista (dreadful OS, I know) and start the server up and running so I can practice before I start coding this coming Monday. If you have Vista then you can easily write and test your own ASP scripts without downloading a thing you just have to setup IIS. Here’s how you do it:

Setting up IIS for Vista

1) Go to your control panel > programs > turn windows features on or off

2)  A box will popup with a bunch of expandable folders. Find the Internet Information Services and check the box. Also make sure the sub-folders Web Management Tools and World Wide Web Services is checked.

3) Say okay to the changes. A box will come up saying its configuring the changes. Might take a few minutes, just let it do its thing.

4) Once its done you’ll notice a new folder under C:\inetpub

5) Inside inetpub there should be several folders. Any work you do should go into the wwwroot folder. If you want it to be the page that loads by default you should call it default.asp which is synonymous with html’s index.html and php’s index.php.

6) If you want to look at your files all you have to do is go to http://localhost in your browser window. You shouldn’t see a 404 File Not Found error. If you did then something went wrong. It could be 1 of 3 things:

1. IIS wasn’t installed correctly

2. Your IIS server isn’t turned on (see further down)

7)  Before you can put up any ASP pages you need to do one more configuration. Go back to control panel > programs > turn windows features on or off. Find the Internet Information Services folder again and click the + to expand it. Click the + next to the folder World Wide Web Services and again on Application Development Features. Make sure all of those things are checked.

8) Click okay to save your changes. It’ll take a few minutes again. Once that’s done you can put in your own .asp pages and start programming to your heart’s content.

9) If you want to turn the server on or off you’ll need to run the server on. To do that you have to open the IIS manager. Go to control panel > system and maintance > internet information services manager. I suggest you put a copy on your desktop so its easier to get to later. On the right hand side of the IIS manager you’ll see text links that say start the server, restart the server, and stop the server. Use those to turn the server on, off, or reset it.

10) Take a look around the manager. You can change the settings in there if you’re an advanced user and know what you’re doing, otherwise I suggest you leave all the default settings. All done!

Active Server Pages (ASP)

These are a lot like PHP, everything is run server side before the page is returned to the browser so you’ll never actually see the ASP code when the html is displayed. I’m going to assume you’ve programmed before and the stuff below will make sense, when writing an ASP file make sure you put the .asp extension at the end. ASP looks a lot like Visual Basic (VB) so there’s not much new to learn. For an editor I use notepad++, notepad or vim but you can use pretty much any text editor out there.

Tags

Start tags and end tags for asp scripts are <% and %>.

Base Encoding Language

You can change the coding language from VB to Javascript. By default its VB but if you’d like to use javascript you need to include this at the top of every ASP page:

<%@ language=”javascript” %>

Comments

All comments start with a single quote (’) and can only be 1 line long. I’m sure there’s a way to do a block quote but I haven’t figured it out yet:

‘This is a comment

Variables

Declaring a variable is easy, although so far I haven’t found any way to declare and set a variable at the same time. Perhaps you can’t. Capitalization is important in ASP, don’t neglect it!:

dim varname

varname = “mystring goes here”

varname = 2

varname = 7.14

Writing Text & Variables

In order to write to the screen you have to use the response object.  If you want to concatenate variables into a string you have to use the & sign. You can include any of the regular html tags as well. If you use a double quote (”) make sure you escape it:

dim mystring

mystring = “Hello”

response.write(”<b>” & mystring & ” world</b>”)

Arrays

These have a weird syntax in my opinion but who am I to judge?

dim length
length = 3

response.write(”this is an array syntax: <br/>”)

dim array(length),i
array(0) = “Hey”
array(1) = ” There”
array(2) = ” World!”

‘Print out the array

For i = 0 to length
response.write(array(i) & “<br />”)
Next

Potential Game Engine

C, C++, Game Developement, News, Programming, Virtual Worlds & MMORPGS, White Oak Stables No Comments

So the bad news is I spent a good 5-6 hours downloading a lot of game engines, perusing through the soure code, and trying to complie it on my machine. Most of them were very annoying and I ended up giving up fairly quickly. A few of them had really, really slow FPS rates (*cough* OGRE *cough*) and if they were slow on my computer they have no chance in a multiplayer setup.

The good news is I found one I really liked. It’s called Irrlicht. The engine is completely open source so I can add to it as I need to (unlike some of the others) and its not so overly complex that I’ll have to sit there digging through hundreds of lines of code to figure out why some pointer is being called differently in some special circumstance…. you get the idea.

So Irrlicht supports DirectX and OpenGL. It’s platform independent which was a HUGE concern of mine. I want my 3D version to work on any computer since I have such a wide member base. It has character skeleton animation, environment mapping, realtime shadow rendering, particle emissions, collision detection, mesh importers, and XML parsers. Pretty much everything I need and want for this 3D project.

I’m going to go ahead and download some other tools they’ve developed for Irrlicht and some more demos from Si02. The beauty of it is I can go ahead and setup some default places on the WOS game map to play around with. Given this engine I think I can have a 3D landscape and animated horse up and running fairly quickly (yay!!).

In the next few weeks I’ll be working on getting a simple scene setup. I want a flat plane textured with green looking grass, and a 3D horse. I want the horse to play some kind of simple animation. Hopefully if I run into any snags I’ll be able to bug the people in the forum to get it sloved quickly.

Here are some pictures of the engine at work!! Click for a closer look.

« Previous Entries