So, our prototype is almost done and I must say, it turned
out really cool. Most of the features are in place and I just have to tweak
some random values and hardcode the GUI. Let’s take a look at the features I’m
done with and how I dealt with them.
1. Swiping
In our game, essentially there are two
kinds of swiping actions:
-
Left and right swipe to switch between different
cheeses.
-
Forward swipe to flick the cheese.
Figuring this out was pretty
simple. So basically, I check for two points say A and B. A is where the player
touches down and B is where he lifts his finger while swiping. To check if the
player presses within a cheese, I use MOAIProp2D’s ‘inside’ function. Then I
calculate dx and dy.
Now, if dx>dy then the Left or
right swipe action is started depending on the direction of the swipe, and if dy>dx
then I activate the forward cheese flick action, which flicks a block of cheese
towards a particular customer.
2. Random customers and movement
In our game, there are 4 random values to be
dealt with:
i.
When to spawn customers? - Using MOAITimer and
callback function I spawn customers at random intervals generated by
math.random()
ii.
Which type? – Using math.random(1,4) on the file names of the
four customer sprites.
iii.
What lane? Using math.random(1,4) for the 4
lanes.
iv.
What speed? Using math.random() again
I have used MOAIProp2D’s moveLoc() to
move all the props, since moveLoc() is relative. For the customers, I’ve
changed the MOAIEaseType to MOAIEaseType.LINEAR because it looks more natural
and the default MOAIEaseType.SOFT_SMOOTH made it seem like the customers were
on drugs. :P
3. Collision detection and cheese-customer matching
So, after the cheese is flicked I create a thread using MOAICoroutine, which polls the flicked cheese’s and customer’s current position. Then using, prop:inside I check to see if the two props collide.
Now, to check if the correct cheese was thrown at the correct customer I call the checkForMatch() function, which essentially is a bunch of if-else conditions (since Lua does not support switch conditions). If it matches, then a update the ‘No of customers satisfied’ textbox and add a green smiley to the status bar, and if it does not match then I add a red smiley to the status bar.
4. Drop cheese and Cheese wheel (Work in progress)
So, I am almost done the drop cheese feature ( in case of correct customer-cheese matching the customer drops a piece of cheese). Collecting the dropped cheese pieces fill up the cheese wheel, which is basically an emergency last resort button that satisfies all the customers with the right cheeses, in case you’re swamped with a lot of customers or you’re losing. I’m not sure whether I’ll be able to finish the cheese wheel by tonight and whether we’ll be able to add it to the
prototype, but I’m going to give it my best shot!
So, after completing the drop cheese feature I’m going to work on the UI. The Photoshop work is mostly done I just need to touch up on a few things.



No comments:
Post a Comment