Jump to content
MakeWebGames

A Somewhat Gradient Name


SMOKEY_TEK

Recommended Posts

Why would he need to read it easier, hes plugging into a functions page and never looking at it again except maybe to change the colors. Also, take a closer look, mine is alot easier to read, all you need to know is the name, and colors.

I believe, people like to learn from code posted on here, therefore your code (all scrunched up, on-liner doing all the work) is unreadable to most.

$newName = ''; not needed to dot-add in php

Yes it is, otherwise it will throw an undefined variable notice. Let me guess you develop with notices turned off? (not wise & lazy)

At the whitespace comments:

Personal preference, once again I enjoy the fact that my code can be read by other people. ;)

-DJK.

Edited by Djkanna
Added Whitespace answer.
Link to comment
Share on other sites

If you take from the code I posted before, you could try;

<?php
$username = 'Smokey';
$colours = array (
   '#FFF',
   '#000',
   '#eee'
); //Add more...

$newName = '';
for ($i = 0; $i < strlen($username); $i++) {
   $newName .= '<span style="color: '.$colours[array_rand($colours)].'">'.$username[$i].'</span>';
}
echo $newName;
?>

To generate a random value of that colours array and use that value as that characters colour, however this will change each page load, and has the possibility to pick the exact same colour for each character.

(script it untested but should work fine.)

Link to comment
Share on other sites

I play this some what new text-based game, all mostly in Javascript and Ajax. And they have a custom name where you can pick a color and then pick a letter for where you want that color at, and so on.. Just not really certain on how to do this.. I really like the idea that they have, and want to incorporate that into my game if I'm able to find a solution to it.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...