ive been working on this game in javascript and i have a couple of questions.

1)how can i make it run faster by either preloading the pix or just using colors(cant figure out anything that can change colors with javascript) when its online? (try it out online and from your comp to see the speed difference)

2)is it possable to make a random level generator that will check if its possable to win?

here's a link to download it
http://www.startbeat.com/games/ColorPuzzle.rar

here it is online
http://games.startbeat.com OR http://www.startbeat.com/games/

please dont rip it off and take credit for it

thanx in advance for any help you can give me

rlemon

08-15-2005, 05:08 PM

your game does not work in FireFox, however It loads fine in IE.

Good Work soo far, btw the colour thingy you wanted is easy.

I havn't looked at the code so i don't know what your using for the blocks. i'm assuming you could use div tags or table cells.

also, I think you might need to place something in there for the <td> element to take the background color. I would suggest using the same image file for them all. Make the image a fully transparent gif 1px*1px

Also, rememember when using the Array that the first element is actually number '0' not number '1'.

tip:
to return the actuall number of elements in the array you would use

var num_of_elements = ArrayName.length-1;

you minus one because it registers 0 as a number.

rlemon

08-15-2005, 07:33 PM

Also, for the random level thing.

I'm assuming there is a seperate page / function for the new levels?

If so, you should only need to generate a random number to distinguish between them and navigate to them.. so...

var randomNum = (Math.Random()*(numberYouWant-1))+1;

the random number will be between 0 and the number you times it by.

so if you wanted a random number between 1 and 9 you would use the following.

var rnd = Math.Round(Math.Random()*8)+1;

iamabe666

08-15-2005, 07:39 PM

i no, but anything random might be impossable to win, im gonna try to have a function that checks if the level is possable to beat and if not trys again, im not gonna work on that till later tho. thanx for your help

rlemon

08-15-2005, 07:53 PM

well if you have say, 50 levels mapped out (however your defining the levels) then you could have a 'load random level' function that just selects from the group.

Might be an easier temporary solution.

iamabe666

08-15-2005, 08:03 PM

i made a level editor, the idea of the random levels is so i dont have to go through each one making it and testing to see if its beatable

iamabe666

08-15-2005, 08:30 PM

does anyone have like 10mins to look through this and see whats wrong, i did the whole table thing and i got an error and i cant seem to find it. heres the link: http://games.startbeat.com/color.html
heres the old one: http://games.startbeat.com/OLDcolor.html

ill post if i fugure it out

rlemon

08-15-2005, 09:02 PM

when defining what values are to be passed to the function you need to encase them in quotes. unless of course you want to pass a variable, or a constant.

so line 18, cc(youold,#ff0000) should be cc(youold,'#ff0000') *assuming youold is a variable.

try that and see if it solves the 'iniGame() is not defined' error as well.