Scripting Guru needed Word Puzzle Game

I am in need of a count down timer script that stops the game and goes to the Game Over screen once it hits 0. That is the first script. The second is I have a game where the objective is to spell out a word by rearranging tiles and lining up the correct letters vertically or horizontally. In later stages I need the game to either end when the time runs out or the player to be taken to the next scene. I have my (TEST) menus setup and the movement down. But I am lost from here.

If you’re looking for a programmer to work with directly, I’d give the ‘collaboration’ or ‘paid work’ forum a try.

If you’re just looking for some tips on how to get started, perhaps you could describe more specifically what you need help with.

I need help figuring out how to trigger the win screen once the player lines up the cubes and spells the word out. Right now, I can move the cubes and spell out the word. But the time keeps running from 60 sec. to 0 sec. to negative numbers. Even if I line up the cubes I cant figure out whats to do next…

What information do you have about the location of the cubes? Are they stored in an array or some other container? Or do you need to determine the order based only on their transform positions?

As of now the cubes are prefabs with this script attached:

Now there are 15 cubes n 16 possible spaces to move to. Once the cube is clicked it moves up, down, left, right to the open slot. If there isn’t one then the cube stays still. Think of a sliding picture puzzle game. The cubes as of now are just black and white, the letters will be textured on. I need to be able to have the game randomly display a question on screen, and the timer begins and the player has to slide the tiles and spell out the word.

I see a couple of potential issues with your script. Most notably, an exact distance check against the value ‘1’ is probably not a good idea due to floating-point precision issues. (It may work under some circumstances, but it’s likely to fail under others.)

Regarding the problem of detecting when a word is completed, it will be easiest if the cube game objects are stored in a 2-d array or some other container that allows you to access the cubes using 2-d indices. Then, to determine whether the word has been completed, you would iterate over the cubes in each row and column, checking as you go to see if the word has appeared in its entirety in that row/column. (There are some additional details of course, but you can always post back with any additional questions you have.)

Thanks for the reply. My first question is would the same method work for colored cubes?

My second question is are there any known examples or tutorials? I am an artist and while I am trying to learn Javascript, it is really kicking my ass :). I am also willing to pay for this script if your are willing to help me or know someone.

I’m using a script in my game similar to the one you want for the Game Over Screen. Mine goes to the game over level when the player’s health hits zero, so all I have to do is change the health to a timer and then you can use the script for your game.

var timer = 300.0;
var countdown = 1.0;

function Update () 
	{
	timer -= countdown * Time.deltaTime;
	if (timer < 0)
		{
		timer = 0;
		}
	if (timer == 0)
		{
		Application.LoadLevel("GameOver")
		}
	}

function OnGUI ()
	{
	GUI.Box(Rect(10, 10, 60, 20), timer);
	}

This code should make a timer that gives the player 5 mins to complete the word. Change the value of the var timer if you want more or less time. It also shows the time in seconds in the upper left hand corner. When the timer hits zero it will load the game over screen, but in the section of code that says:

	if (timer == 0)
		{
		Application.LoadLevel("GameOver")
		}

You’ll need to change “GameOver” to whatever you titled your game over scene.

Sometimes you can find examples or tutorials for specific things like this, but if your needs are specific enough, it’ll most likely need to be coded from scratch.

There are quite a few folks on the forums who do freelance scripting. I might be able to help you (you can PM me if you like), or you could just post in the ‘paid work’ forum. (If you were to post your request there, I’m sure you’d find someone to help in no time.)

@XZ001 THANKS, but i keep getting this error.

If I remove that portion the errors go away, but nothing appears onscreen.

Sorry, minor error. (Gotta hate how it only takes one tiny thing and an entire script wont work)

function OnGUI ()
	{
	GUI.Box(Rect(10, 10, 60, 20), "" + timer);
	}

Just add those quotation marks. You can also put a string in them, such as Timer: to indicate that the box is giving you the time you have left. If you do, I suggest increasing the box’s length. Just change the 60 to about 100 and that should be enough room to add in “Timer:”

@ XZ001

From the looks of it the problem is that the function is expecting a string while you are putting in a float.

While "" + timer does apparently work in JS (It seems to be giving the compiler enough info to implicitly figure out the type) timer.ToString() is preferred.