Random words

Started by Cpt Ezz, Thu 08/01/2009 12:37:29

Previous topic - Next topic

Cpt Ezz

i know things like this have been answered many times but it is not what i want

i'm making a game to help kids that are having trouble learning words ages (5 - 10) and i want a animal to walk a acrose the view and make a noise, a bark what ever then here is my problem i want 3 or more buttons or GUIs to display words (if it is a dog it to say dog, cog and dot) or something and then you can pick what one is right. THree questions how do i make that if you get dog twice the answer is not in the same place?do i make a score for getting it write?
how do i make it so whatever answer you chose you change rooms?

could it please be in script?

Ghost

Quote from: Cpt Ezz on Thu 08/01/2009 12:37:29
THree questions how do i make that if you get dog twice the answer is not in the same place?do i make a score for getting it write?
how do i make it so whatever answer you chose you change rooms?

could it please be in script?

For the first question, I can't figure out what you mean, can you be a bit more precise?

2: How do I make a score for getting it right:
GiveScore(int points)
GiveScore(10) will give ten points, and so on.

3: How do I make the player change rooms:
player.ChangeRoom(int Room,  int x,  int y)
player.ChangeRoom(10) will just set the new room to 10. x and y are optional.

You seem to be new to AGS, so make sure you read through the tutorial.

And without me wanting to sound harsh, make sure you let someone proof-read your game! Educational games are *always* under attack as soon as they even get a common comma wrong!

Cpt Ezz

what i mean in the first  question is if i have three words too chose from lets say a,b and c and the right answer is c next time i play the game i don't want ithe correct answer to be in the same place

and want i really mean about the change room thing is that there is no character as such but when i click on a answer i want it to change rooms, is it any differant then the normal way,
sorry about the stupid questions and it may seem that i'm new but i have been using ags for about half a year but i just don't get somethings i have started learning C now to help

Ghost

There are no stupid questions, as they say.

Okay, first about the ChangeRoom command. You will always have to have the player character in a room, but you can make him invisible, or you can give him a view with a blank sprite so that he doesn't show up. Moving the player character from room to room is the only way to change rooms, so my tip is valid.

And about the answer shuffling, well... This would involve some medium-to-advanced scripting. Do you always have three choices? In that case, you could make a struct and write yourself a function that distributes the answers at random, and this would also allow you to keep track of the "correct" answer...

Cpt Ezz

but how would i script a function like that, seems long and annoying
and how would the character change rooms if a curser clicked a box/button the character really was nothing to do with it


Khris

There doesn't have to be a visible character that walks to a screen edge or something; calling player.ChangeRoom(2); will always load room 2, regardless of the player's position, visibility and/or appearance. So putting said command in the buttons' OnClick function is all it takes.

I'd say the easiest way of representing the animals is using characters (in theory, you don't have to use more than one room, although this is probably an easier method for a beginner).
Set the starting room of each animal character to its designated room, then switch rooms by making that animal the player character (this is the alternative method of changing rooms).

Create the animal characters, select one of them, then add a few Custom properties, one for each button, of type String. As name, enter "correct" for the first one, then "wrong1", "wrong2", etc. for the others. Leave description and default value blank.
Exit the schema editor and enter the correct and wrong names for each animal character.

I have to go to bed now; I'll get back here tomorrow.
If anybody else wants to pick up: I'd put code in the on_event/eEventEnterRoomBeforeFadein that'll randomly distribute the property strings among the buttons. A button click will then compare its text to the "correct" property of the player and give score if equal, then change the player to a random other animal character.

Cpt Ezz

i get the drift but in a giant clupp of words it doesn't make much sense can someone please put it in script form?

thank you by the way guys

Khris

The method I chose requires you to do some additional work besides scripting, as I explained in detail up until the last paragraph. Did you actually read my post..?

Cpt Ezz

no i just posted a post for no reason, yes i read your post i just don't get the wrong right thing and the oevent stuff

Khris

One can't "put it all in script form" for you to Ctrl-C Ctrl-V the whole thing.
If that were possible I wouldn't have wasted two paragraphs explaining about creating characters and assigning properties to them. I even linked to the manual page.

What exactly are you having problems with?

Cpt Ezz

#10
i just had a great idea :o
in stead of using guis i can use objects
all i need to know is how to make the three choices change position
i will post a picture in a few minutes

Cpt Ezz

#11


the red areas at the top are the three options
how do i make does mix up?

Matti

#12
Well, you can't simply post a picture here which is actually located on your harddisc. You need to find a host to upload the image. The second point is that you need to post the file extension of the image too.

http://www.adventuregamestudio.co.uk/yabb/index.php?topic=6297.0


Edit: You can upload pictures here for example: http://www.2dadventure.com/ags/upload/upload.html

Cpt Ezz

thank you for posting that here is my picture
http://www.2dadventure.com/ags/Joe's_Farm.bmp
red squares at top are the places were the buttons will apear
the rest is prity self explainitory
so all i need to know is how to mx them up thanks

Ghost

#14
Simplest way, just make a "random setup" for a couple of positions.

Let's say your objects are called oThing1, oThing2, oThing3.

In the room's "before fadein" function, enter this (or something similar):

Code: ags

int rnd = random(5)
int left = 60;
int middle = 160;
int right = 240;

if (rnd == 0)
{
  oThing1.x = left;
  oThing2.x = middle;
  oThing3.x = right;
} else 
if (rnd == 1)
{
// another combination
}
.
.
.
else
{
// yet another combination
}


Just set up several combinations of positions, and off you go. Take care you provide as many combinations as possible to keep things interesting. Of course, with three buttons you only have 6 possible layouts (left/right/middle - left/middle/right - right/left/middle - right/middle/left - middle/left/right - middle/right/left).

That's a rather simple way though, and means some typing you could totally avoid by using Khris' method. Using strings would allow you to simply change text, and thus you could have a larger pool of "wrong" answers.

Cpt Ezz

thank you very much
ghost and KhrisMUC you have been great
your advice and script was very helpful

SMF spam blocked by CleanTalk