Go Back   Photics Forums > Photics Round Table > Animation and Game Development

Reply
 
Thread Tools Display Modes
  #1  
Old 08-19-2005, 01:30 PM
Photics's Avatar
Photics Photics is offline
Webmaster
 
Join Date: May 2005
Location: Staten Island, NY
Posts: 3,284
Blog Entries: 74
Photics is on a distinguished road
Default

I was working on a new Guild Wars web game for Photics.com, but I hit a snag. See... not only do I hate the refresh tag, I am not allowed to use it with certain advertisements. So, by eliminating the refresh tag, a plain static page would appear over and over. I was thinking some random text would make the game feel more dynamic... kinda like the loading screen in Neverwinter Nights or Knights of the Old Republic.

The problem? I'm no coder. I'm something like the Borg of web design. I find new technology and assimulate it into my own website. Yet, that's just not going to fly if I'm going to be making new games. Sooooooooooo... Nemi heard about what was going on. That's when he told me about the rand() command in PHP.

I'm still fuzzy on the whole writing my own code thing. But based on what Nemi said, I did manage to come up with this...

Code:
<?php

$array[0] = "Hi Nemi!";
$array[1] = "What calls us is victory!";
$array[2] = "This is randomly created text!";
$array[3] = "DON'T LOOK AT ME!";
$array[4] = "Buy Mike's book!";

$randomVar = rand(0, 4);
echo $array[$randomVar];

?>
Now... I can drop that into the game for a dynamic effect. :)

Wooo hooo... I'm learning PHP :lol:
__________________
Michael Garofalo
Webmaster - http://photics.com
Reply With Quote
  #2  
Old 08-19-2005, 03:06 PM
Ronduwil Ronduwil is offline
Knight
 
Join Date: May 2005
Posts: 373
Ronduwil is on a distinguished road
Default

I'm not a seasoned web developer or anything, but can't you just put the refresh tag in a given frame so that only that frame refreshes itself? If so, you can still use the refresh tag without violating any agreements with your advertisers.
Reply With Quote
  #3  
Old 08-19-2005, 03:18 PM
Photics's Avatar
Photics Photics is offline
Webmaster
 
Join Date: May 2005
Location: Staten Island, NY
Posts: 3,284
Blog Entries: 74
Photics is on a distinguished road
Default

Quote:
Originally Posted by Ronduwil
I'm not a seasoned web developer or anything, but can't you just put the refresh tag in a given frame so that only that frame refreshes itself? If so, you can still use the refresh tag without violating any agreements with your advertisers.
Did I mention how I hate frames too?! ;)

Actually, it's difficult to explain without showing the game... and I'm not ready to do that yet. Plus, this adds an interesting element to the game... one that I think will actually create a sense of travel. I'd use a second game as an example to say you're right. There are ways around making the whole page to load. Yet, I'm not sure that developer is ready to talk about his game yet either.

Soon... there will be NDAs for everyone! HA HA :lol:

In this case, I'm fairly certain frames would not have helped me... and I like this solution so much better. This game should to run great on a T-mobile Sidekick II... which doesn't support the META-REFRESH command.
__________________
Michael Garofalo
Webmaster - http://photics.com
Reply With Quote
  #4  
Old 08-19-2005, 04:11 PM
Amaranth
Guest
 
Posts: n/a
Default

Quote:
Originally Posted by Photics
Code:
<?php

$array[0] = "Hi Nemi!";
$array[1] = "What calls us is victory!";
$array[2] = "This is randomly created text!";
$array[3] = "DON'T LOOK AT ME!";
$array[4] = "Buy Mike's book!";

$randomVar = rand(0, 4);
echo $array[$randomVar];

?>
'course, its more efficient to do it more like ...

Code:
<?php
switch (rand(0,4)) {
    case 0:  echo "Hi Nemi!"; break;
    case 1:  echo "......"; break;
    ....
}
?>
You get to avoid the allocation and initialization of the array that you won't be reusing.
Reply With Quote
  #5  
Old 08-19-2005, 05:00 PM
Nemisari's Avatar
Nemisari Nemisari is online now
Knight
 
Join Date: May 2005
Posts: 537
Nemisari is on a distinguished road
Send a message via AIM to Nemisari
Default

Quote:
Originally Posted by Amaranth
'course, its more efficient to do it more like ...

Code:
<?php
switch (rand(0,4)) {
    case 0:  echo "Hi Nemi!"; break;
    case 1:  echo "......"; break;
    ....
}
?>
You get to avoid the allocation and initialization of the array that you won't be reusing.
This code served multiple purposes .. since Photics doesn't have any formal training in programming, the code fragment I helped him with introduced the topic of variables, arrays, and functions which he can reapply later :)

you are correct .. switch would have been more efficient, but it wouldn't have helped Photics any ;)
Reply With Quote
  #6  
Old 09-03-2005, 07:08 PM
Photics's Avatar
Photics Photics is offline
Webmaster
 
Join Date: May 2005
Location: Staten Island, NY
Posts: 3,284
Blog Entries: 74
Photics is on a distinguished road
Default

Quote:
Originally Posted by Nemisari
This code served multiple purposes .. since Photics doesn't have any formal training in programming, the code fragment I helped him with introduced the topic of variables, arrays, and functions which he can reapply later :)
I don't know what any of that means, but I certainly did reuse this code. It's on the main page...

http://photics.com/

...can you see where? :D
__________________
Michael Garofalo
Webmaster - http://photics.com
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Forum Jump


Portions of this website are part of the Guild Wars Fansite Program. Guild Wars is a trademark of NCsoft Corporation. All rights reserved. Arena.net, ArenaNet and the ArenaNet logo are trademarks or registered trademarks of NCsoft Corporation in the U.S. and/or other countries. The Photics.com webserver is powered by HostRocket.
All times are GMT -4. The time now is 12:03 AM.

Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.