How can i create an odometer/rolling meter life system like in the MOTHER series in Gamemaker Studio 1.4? - game-development

I'd like to create an odometer life meter like in the MOTHER series, anyone knows what i can do?
I've already tried to search on google, i tried it to do myself but the only thing i got is a shitty meter which doesn't even display the right amount of health (this is for an Action-RPG btw.)
I would just like to recreate the odometer system in the mother games in to my project, could (please) somebody tell me how to do that/or give me tips about it?

do this in gms2:
create a control object if you still do not have it;
in create event
// #description event create
// variable lives or odometro
global.odometer = 5; // Example of player lives
in step event
// #description event step
// you create the condition to gain life
if (keyboard_check_pressed (vk_up)) // example of condition
{
// create your actions by gaining life
global.odometer ++;
}
// you create the condition to lose life
if (keyboard_check_pressed (vk_down)) // example of condition
{
// create your actions by gaining life
global.odometer -;
}
in draw event
// #description in draw event
// example of how you will show your odometro, create yours with your sprite or your odometro object
draw_set_color (c_red);
draw_text_transformed (x, y, string (global.odometer), 10,10, image_angle);
// Place the control object in the empty room and test it.

Related

Go To Definition - getting back again

I am looking for a simple means of jumping back from a Go To Definition action, which goes directly back to the point from which I made the GTD jump.
The problem with the current workbench.action.navigateBack feature is that it revisits other locations over which I have moved the cursor (after making the GTD jump) before returning me to the point where I started. For instance:
public takeoff() {
this.landing();
}
public landing() {
let x = 1;
let y = 2;
...
...
}
If I choose Go To Definition to move from takeoff() to landing() and then move the cursor up and down the lines of code in landing(), when I issue the workbench.action.navigateBack I simply want to return to takeoff(), but instead I have to revisit various lines within landing() along the way. Aaargh!
Do you know how to achieve the functionality which I am looking for?

Javascript loop with event action listeners and buttons

I am trying to write an app that has a multiple choice quiz in it. I am writing it in a simple and somewhat hardcoded way. I have created an array of questions and a 2-d array of answers as my "database". My problem is that when i am iterating over the loop, my app immediately goes to the last question, even though if statements that in an ideal world should let the user interact with every questions.
my while loop is
var i = 0;
while i<10 then
make the question view
make the answer view
make the answers clickable
calculate scoring
if the next button is pushed and i < 8 then i+=1
/*this prevents the app from building but when i put the i+=1 outside this control statement it goes directly to the last question in my database*/
end While
any ideas? my code is really long and do not know if i should post it
Rather than doing it all in a while loop, you should take a slightly different approach.
Create a function that does the while-loop-block above, and use a variable to keep track of the currently displayed question and answer. Then when the user clicks next, advance to the next pair, until the user is done.
var current = 0, until = 10;
function showCurrent() {
// make the question view
// make the answer view
// make the answers clickable
// calculate scoring
}
function goToNext() {
current += 1;
if (current === until) {
// carry on with whatever is next
}
else {
showCurrent();
}
}
showCurrent();

What's the frame to write Kinect skeleton track program with gesture users can define with C#?

I'm writing program about Kinect skeleton track program.While the Definition of the gesture is written in the program. I want the definition of gesture to be defined by the user.One way of doing this is by DFA. I don't konw how to start with C#. Can any one help?
Try using Lists to store the coordinates of the skeleton's joints (kind of a buffer) and then you could maybe run a DFA. you could define your transitions as a range of coordinates for every direction , and the final state would be when the elements in the buffer are approximativily in the same area.
So in C# you will need to create a datatype to save the sequece of the gesture that will get updated when the user adds one.Lists for buffers as I stated below.
When saving the gesture your code will look like :
While(!Joint_stable && (i < buffer.count() ) )
{
While ((buffer.Joint.ElementAt(i+1).X-buffer.Joint.ElementAt(i)).X>0 && (buffer.Joint.ElementAt(i+1)-buffer.Joint.ElementAt(i).Y )>0 ) //Think about adding tolerence here
{
Gesture.add("Upper_Right");
}
...
}
Just an advice , the kinect sensor is not that accurate so try to establish a kind of tolerance.
I Hope that my answer will help you or at least give you some inspiration :)

Box2d - Changing contact filter on the fly

Im using cocos2d (iOS) and box2d to create a game.
I have come to the point where I need to change the contact filter mid simulation and wondering how to go about this.
I need to use maskbits and categorybits, which is fine, im just unsure how to apply them to a b2body mid game.
I'm thinking I may need to retrieve the original b2fixture or b2fixturedef of the b2body on initialization, alter the values accordingly then call a method to refresh - world.Refilter()?
Does this sound somewhat accurate?
Any advice is surely appreciated
Oliver.
b2Filter filter;
for ( b2Fixture* f = body->GetFixtureList(); f; f = f->GetNext() ) {
f->GetFilterData( &filter );
filter.categoryBits = ...;
filter.maskBits = ...;
filter.groupIndex = ...;
f->SetFilterData( &filter );
}
Obviously this would change the filter settings for all fixtures on a body - if you want to be more selective you will have to be able to tell which fixture is which somehow. Eg. if you know it's the only circle fixture you could just look at the type of the fixture to decide, otherwise you would have to make use of the fixture's user data I guess.
You can iterate over all bodies in the b2World. On each body you can iterate over it's fixture and change it's filter. To identify your bodies you can use userData.
The answer from iforce2d might be obsolete. I got the following code working properly with box2d v2.2.1, cocos2D v2.0.0 using Xcode v4.5.2 (here I assume I have a pointer to a b2Body named 'body' with only one fixture, i.e., I don't iterate over all fixtures on the body):
b2Fixture *fix = body->GetFixtureList();
b2Filter filter = fix->GetFilterData();
filter.groupIndex = -1*kPlayerGroupIndex;
fix->SetFilterData(filter);
In the above code I prevent 'body' from colliding with my player body which also has the same groupIndex value, i.e., -1*kPlayerGroupIndex, where kPlayerGroupIndex is a positive integer constant. Any bodies with this negative groupIndex never collide with one another. You could also update the categoryBits or maskBits accordingly to prevent collisions.
GetFilterData(&filter) and SetFilterData(&filter) returned errors for me given the version numbers I quoted above.

Handling player on turn with Objective C

I'm creating a simple app which has a list of characters and a list of (4) players, the players is simply a reference to a playable character.
I'm stuck on how to do the following:
Make a reference to the current player on turn
Find out who the next player on turn is
Handling the last player so that it will return to the first player on turn.
Ideally, I would like to be able to do AFTER, FIRST, LAST BEFORE commands on a NSMutableArray, of these I'm able to do lastObject, but there is no firstObject, afterObject, etc.
I believe you can fake BEFORE,AFTER,FIRST commands with objectAtIndex; but ideally I do not want to rely on numeric references because it could be incorrect -- also if its mutable, the size will always change.
Typically, I would be able to do the following in Pseudocode.
Global player_on_turn.player = Null //player_on_turn is a pointer to the player object
; Handle next player on turn
If (player_on_turn.player = Null) Then Error("No player on turn assigned")
If (sizeOf[playerList]==0) Then Error("There are no players in the game")
If After player_on_turn = null Then
; We reset it
player_on_turn.player = First player
Else
; Move to the next player on turn
player_on_turn.player = After player_on_turn.player
End If
With this in mind, what is the best strategy to help handle a player on turn concept as described in the 1-2-3 example above.
Thanks
It probably doesn’t matter what data structure you’re using - at some level you will have to rely on a numerical index (except if you are using linked lists). And this is alright. If you don’t want to use it in your main game implementation that is alright, too. Just create a class that encapsulates those things. First think of the operations you need it to support. My guess here would be those:
- (PlayerObject *) currentPlayer;
- (void) startNextTurn;
If you have this you can write your game using those primitives and worry about how to best implement that later. You can change those at any time without breaking your actual game.
My recommendation would be something like this:
- (PlayerObject *) currentPlayer; {
return [players objectAtIndex: currentPlayerIndex];
}
- (void) startNextTurn; {
++currentPlayerIndex;
if (currentPlayerIndex >= [players count]) {
currentPlayerIndex = 0;
}
}
Using the index there is OK, even if the array is mutable. If you have methods that change the player array they also can take care of the necessary changes to the currentPlayerIndex.
Having this object makes it easy to write unit tests. The global variable you suggest in your pseudo-code makes it impossible to write meaningful unit tests.
Use a State Pattern for the main runloop of the software. Draw it out as a diagram and create variables to control which state the system is in.
You should use a circular list of the players to return current, next, and previous players.
This is also a great question for GameDev on the Stack Exchange.
PS
CocoaHeads puts out a relatively nice set of data objects, including a circular buffer.