Randomize falling blocks
I'm currently making a game for Japanese learning students. At the top of the screen there is a box which spawns a random hiragana character (basically a letter) every five seconds. Three blocks fall from the screen, two of which are red and one of which is green. (There is no space between the blocks or the edge of the screen.) Underneath the red blocks there is an incorrect pronunciation of the hiragana character, while the green block has the correct pronunciation. The red blocks will collide with the player and cause them a penalty, but the green block will pass harmlessly over the player. The player needs to navigate under the green block to survive.
tl;dr I need to automate three falling blocks, two of which are red and one of which is green, along with the correct pronunciations underneath.
What would be the best way to code this? I've tried many different methods, like:
http://forums.gamesalad.com/discussion/90330/random-spawning-on-a-grid-help#latest
- Assigning a random integer from 1-3 to an attribute called "space" (the three points on the screen the blocks spawn from) and a random integer from 0-1 to an attribute called "typeBlock" (green or red), listing each probability in a "Rule: if space=1 and typeBlock=0, spawn green at ___, else if space=1 and typeBlock=1 spawn red at ___, else if........." manner
I feel like this should be simple, but everything I try ends up not working.
Here's a very rough draft of what I want to make. Thanks for your consideration, and please let me know if I broke any forum etiquette on here!
Comments
yes its for a japanese class and no im not a weeaboo
No etiquette broken, but I would say that's a lot of information for such a straightforward question, I'm not sure how many people would bother trying to wade through all the tangental stuff about Japanese characters and students and read through the failed approaches and watch a quarter of an hour video and attempt to download something (?) from a broken DropBox link . . . etc.
I'd say the secret to getting a quick answer to a question was to strip away all this extraneous detail - it took me a while to work out what the actual question was !
. . . . . . . . . . . . . . . .
I'd lose all the attributes and rules and stuff and keep it simple:
Spawn the green actor in one of three random L/R locations (random 1-3 * whatever)
Then have the green actor spawn the red actors either side of it - (stick scene wrap X on)
Example attached:
@Socks @hsp ,
I have been working on the same idea:
2 particles(LEFT & RIGHT) spawn 2 elements or spawn anything.
My solution was to create:
GAME ATTRIBUTES:
1. GameSpeed (integer)
2. Frequency (integer)
LEFT SHOTS the element
-EVERY (timer) [GameSpeed / Frequency ] seconds (tick: "run to completion")
-DO (rule):
--RANDOMIZE: if RANDOM (0, 6.5) <= 5.5
---DO (rule):
---SPAWN ACTOR
---ELSE
---RANDOMIZE: if RANDOM (5,10) => 7
DO (rule):
---SPAWN ACTOR
ELSE: empty
BASICALLY,
when GAMESPEED attribute is set to 1 and FREQUENCY is set to 1,
every 1 sec. particle SPAWNS an Actor (e.g. "0 = no actor" ,1 = "green ball" , 2="red ball").
I hope that's helpful
best regards,
J
@Socks @elektroform Thanks so much for your help, the actors are falling randomly now just how they're supposed to (although the green actor falls just a few pixels below the red actors)! I'm really glad it works out though.
Sorry about giving so much information and the broken image, I understand I need to trim that down in the future now lol
I'm now trying to code the pronunciations to spawn underneath the correct blocks, what would be a good way to do this? I don't want two correct pronunciations to spawn on the same character and all.
Sounds like the green actor is getting a head start, place the green actor's move behaviour into a timer to delay it by a little (or use an 'if self.time >X' rule).
It is simply unacceptable, you have been struck off my Christmas card list.
Not sure what that means.
Using a timer seems to work, thanks!
this is the third time today
Does the image attached to the post work now? I want to have three different pronunciations under the three blocks, with the correct pronunciation underneath the green block and some random wrong pronunciation under the red blocks. The pronunciations are actors that are images of the pronunciation, same size as the block themselves.