Soulmachine's Recent Forum Activity

  • Thats BRILLIANT

    I was so stuck at this problem. The solution works so nice.

    If you are wondering, I had that every 0.05 seconds to simulate how an old game work, a game that's been my inspiration. Also I've found if I use something like every tick, in some way. The timing gets different depending on how many FPS you have. So I needed a time based something...

    I mean if I add something to a variable every tick - the time it takes gets different if you got 75fps versus if you had like 30fps. Sometimes I use add dt (delta time) instead and have a real time based kind of delay or timer.

    This solves A LOT for me - in my real project. Thanks!

  • I've been away for a while in the real world, I forgot about programming for a moment but I'm back now...

    Jase00

    I did two CAPX examples. One with Normal steering without any array, and one with the array, as I constructed it when I wrote this post.

    [attachment=1:moo0bvf1][/attachment:moo0bvf1]

    [attachment=0:moo0bvf1][/attachment:moo0bvf1]

    As you can see, if you try to steer right ( rotate right ) with both the player1 and 2 at the same time, it do not work in the array version. But one player at a time works.

    The controls

    Player1 Arrows: Left, Right, Up, Down. Shoot with CTRL

    Player2 Keys: WASD. Shoot with SPACE

    Potato

    Your example are very interesting - I'm reviewing it now to see If I perhaps could use your technique. THANKS for your effort

    -

    If I don't manage to solve this using an Array I'm considering try to do it in another way some how. However I have so much freedom changing and tweaking the values if an Array could be used.

    In my real project I have different animation for each "state" I also have a lot of other things that depends on in which state and what value the array has. Like aiming and I also have a wind factor in my game.

    I'm creating a ship that sails on the sea.

  • Hi Guys!

    I'm not sure how to explain this - or if I'm posting under the right topic/headline. So I posted here in Construct 2 General.

    I'll try and do my best to be as concrete and simple as possible.

    First my problem.

    Construct wont read values from two separate arrays "at the same time".

    What I have is

      a 2 Player game. Player 1 has an own dedicated Array Player 2 also has an own dedicated Array The Player(s) has steering and can be controlled "RotateLeft" , "RotateRight" , "Forward" , "Backward" The Player(s) dont use the bullet behaviour to move or to rotate this is important. So forth I have 16 cells with static values in an Array 0-15, they contain the Angle the player should rotate to. This is used to make a "Direction-Based Sprite Animation" ...Like old school games that has a separate animation-sprite that faces and "walks" in the direction the player is moving. I'm using the array to store the angle the player should rotate to - in 22.5degrees increment . Like 0 degrees, 22.5 degrees, 45, 67.5, 90 degrees and so on. When "RightArrow" are held down - a Function are Called that read a value from the Players dedicated Array. And use that value to set the players angle. ( I explain more further down) The Player object and the Array object are in a container

    The thing is.

    ...And the function works like this:

      I'm holding down "RightArrow" The Keyboard event calls a function: Function Call "SteerRight" ("Player1") I'm sending Player1 along as a parameter. In the function "SteerRight" the first event are a Pick by Comparison, and the player object gets picked that has "Player1" in an Identification variable. Then immediately I set the players angle by reading a instance variable from the player... Player.State and using that to choose which cell from the players Array that should be read. Like this... Set Angle to ArrayPlayer.At(ArrayPlayer.State) After that I have an Event that adds 1 to another variable called KeyDown When KeyDown are Greater than 10 ...I add 1 to the Player.State variable. Then if Player.State are Greater or Equal to 16 it reset the Player.State to 0. So the state starts back at state zero. A full 360degree circle. Thats the function... that gets called constantly as long as I hold down the right arrow-key.

    This works perfectly with ONLY one player.

    The player rotate both clockwise and cclockwise, I can move forward (thats another function with no array) and move backward.

    ALSO when I use the Player2 controls ( WASD) it also works perfectly.

    I have checked the Arrays in the Debug layout and everything looks fine. The Player1 Array are read independently from the Player2 array. I've checked the variables and every instance of the objects and so on. It all looks fine.

    Now here's my problem

    If I hold the right arrow-key down (rotateClockwise) AND the D-key (rotateClockwise for Player2) down simultaneously - the Player1 and Player2 should both rotate clockwise. But they are not.

    Only one of the players do. And the other players Array does not get read at all.

    It's like one array gets priority over the other or something?

    This is a big problem, cause you kind of wanna be able to steer both the players at the same time - otherwise its not a 2 player game

    The big strange thing is that if I use traditional ways to rotate the players IT WORKS???

    I tried this because i first thought you could not call the same function at the same time like this. But YOU CAN.

      If I instead have the function "SteerRight" And inside I simply have Rotate 2 degrees clockwise. ...Yes I send along the "Player1" or "Player2" parameter and have a Pick by Comparison event first, so either the Player1 or Player2 gets picked. Everything works fine. The Player1 and Player2 both can be steered independently and at the same time with no problems.

    I can have as many players as I want this way.

    But if I have the array in the function and I have to read something from one of the arrays cells, it does not work?

    Probably I could achieve the same result I'm after in a different way, without arrays. But I just wanted to know why I cant use a Function Call like this when there is an Array involved?

    Does anyone know what is happening here in the Construct 2 mechanics or have good ideas of what's wrong?

    I apologize for my wearisomely explanations - I hope someone understands them.

    And thanks for reading this far *HUG*

    If anyone wants to, I can upload a .CAPX in the future.

  • I have done some simple experimenting and found that it IS possible to call the same function "simultaneously" and to steer a Player1 and Player2 at the same time using the same function.

    I created a totally clean project and had only the controls and a simple function - it worked.

    then my problem depends on something else - at least I know this now.

  • If I have a function that gets called when a keyboard key are held down and the same function gets called when another key are held down...

    ...is this possible?

    I use a function that should do things to a player object when I press a key. It's about steering an object with the arrow-keys.

    But I have 2 players, and when Player1 and Player2 steer left at the same time - it does not work. ( yes the Player2 has other keys assigned )

    I guess the function can not be called like that "at the same time" ?

    Each call (for Player1 and Player2) gets different parameters. And the function works fine if only one player steer left or right, but if both steer at the same direction at the same time, it does not.

    I have 2 functions, one for "SteerLeft" and one for "SteerRight"

    I guess I have to do this in a different way somehow. I wonder how the mechanics that are in progress here works when the function get calls at the same time?

    If anyone can explain, I'll give you a HUG!

    ///Soulmachine!

  • This version is better :

    lindsjael.se/soulgames/BrainOfAnts_v0.6

    That version has a stack based FSM and I fixed several bugs. <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile" />

    -

    I managed to figure out how to make a stack with the states and it really helps. The transitions gets much better.

    There's just 1 bug left, it's when the ant that GROWS gets destroyed too soon after it has finished growing. Some variables that should be reset at the moment the ant finishes grow, DONT get time to reset, for some reason...

    What I have found out so far - most of the mechanics works now.

    At least the normal states: FindLeaf, GoHome and RunAway works great...

    ...It didn't bug with over 200 instances of ants, <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile" /> <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile" /> coool.

  • Hi again Guys! <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile" />

    With a mix of your help, the internet and some friends I managed to make something close to a FSM.

    You guys pointed me to the right direction to find more info and search for the right things. THANKS! <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile" /> <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile" />

    Also the FOR EACH is a big solution, and I've figured out a way to separate objects even though they are the same sprite but just different instances.

    Nimos100

    I kind of used a similar way that you describe and I have used functions.

    Here is what I've managed to accomplish so far: lindsjael.se/soulgames/BrainOfAnts_v0.4

    I have divided the way construct should check the states of my "Ants" and what to do if they should transition to another state.

    What I did was to make a function I named "FSM"

    That function gets called every tick

    Inside FSM I have a condition-CHECK that with the help of a For Each, checks different conditions and if one are met, sets a "state" for the Ant.

    for example: If Ant has a distance lower than 10 pixels to Leaf - the state "goHome" will be set.

    next inside FSM

    I have another For Each that checks the "states" of all ants and then call a Function.

    ...like If Ant are "goHome" then call Function (goHome)

    This way I have kind of a CHECK - DO combination.

    First there is the CHECK for conditions, and after that comes the DO.

    A downside are that there will be alot of events used pretty fast but on the plus-side are a code that is reasonable easy to manage, understand and modify.

    When a function for a "state" gets called I pass along a parameter... and that is the Ant.UID... This way the function knows WHICH ant to be affected.

    However in the function I always need a "Pick by comparison" -event. ...so the amount of events get pretty large after a while.

    But it works so far. I will work more on this, try different approaches and to see if I can make the events even more cleanly.

    Right now I'm trying to figure out how I could make a "Stack-based" FSM.

    A way to store a state the Ant were in before the active state. So it can go back to that state just by popping the topmost state on the stack.

    like... if the ant are "goHome" but then the ant-eater comes near and the ant need to "runAway"

    when the ant-eater are not a threat no more, the ant needs to get back to the last state it was doing "goHome"

    If I can do this, I don't have to have a condition check for that - the ant could just pop (remove) the active state on the stack, and go back to the "goHome"

    I'm gonna use an Array for this - but I haven't figured out exactly yet where I should put it

    It's easy if you just have only one instance of an object to work with. But when I have a For Each and lots of instances there are a bit more tricky <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile" />

    In my example game there are still some bugs. It's because I ran out of events. I'm at exactly 100 events <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile" /> So I could not fix the last bugs.

    But it works most of the time, and if it is bugging just reload the site.

    I will continue to work on this now. If you like I can post some links that has been useful to me to understand the FSM mechanics.

    However almost ALL refer to the C programming language and working with classes. It's a bit confusing for a non-programmer like me, even though I've made some C# programming in the past. But I'm far away from any programmer <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile" /> I'm just creative.

    If anyone are interested in the CAPX i will upload that one too.

  • Thanks very much guys

    Very interesting... it helps a lot with the explanation on the picking in C2. I will do some hands on work, to learn more about it.

    Right now I'm researching finite state machine and I would really like to learn how I can create a simple one in construct. I want to learn the mechanics so perhaps in the future I would be able to make some sort of AI opponent in a small RealTimeStrategy-game.

    I'm not a programmer, just a creative person that's been working in and around games, and game making. My main function is sound - but I'm interested in all aspects of creating games.

    Any suggestions on websites that explains State Machine from the beginning are appreciated.

  • I really find this post interesting, just wanted you guys to know

    You see potential in this simple little user friendly editor: Construct 2

    I like your commitment Keep up with these very important questions.

  • Hello guys

    How have you solved making a simple State Machine in Construct 2?

    I'm not talking big advanced ones, only minor ones to create some AI-feeling.

    All ideas you may have are appreciated. But please keep it simple So I learn.

    I've experimented with this working with booleans, I'm wondering if there are other ways you could achieve this?

    Right now I'm working on making a "Worker" kind of like in Empire Earth, that gather resources and then unload it in a town house. I've managed, so far, to make it work pretty nicely... However, I'm having problems when I have more than 1 worker active.

    ...So if I have a condition that this specific worker, identified with a unique id - triggers when overlapping this specific resource.

    When I perform actions when these conditions are met - other workers also sometimes do the actions.

    Have I missed something here, on how the mechanics work in Construct 2. On how conditions are met, and actions are performed. What have I been missing? Any suggestions on what may be in conflict would be very helpful.

    How would you design a basic wandering enemy - that has some basic states, like "Roaming" - "Targeting" - "Attacking" - "Evading" ? Using states...

    Ok - that's the question's.

    I now will describe a bit more the problems I have, it can be a bit long to read - but it's not needed for you to read to answer my question, only if you want to.

    -

    ---

    My programming friends says they are using classes when they create State Machines

    sometimes they do it with Switches. Mostly they work in C or Java.

    Booleans or Switches are the only way I can think of right now of using to achieve this in Construct.

    I don't wanna use families, cause I haven't afford to buy the full version of Construct yet.

    There seems to be some conflict in separating the objects in Construct.

    To explain...

    Say you have a state "Found Resource"

    then you want the worker to go to the resource. When he arrived You perhaps have a state like "At resource"

    And later "Extracting Resource". Something kind a like that

    I make this work perfectly using only one instance of my Worker. The states on the worker seems to work good. But when I create a second Worker, or more, some actions are performed on all workers (this I don't wanna).

    Even though I have a unique identification of each worker - to make construct separate different instances. Somehow sometimes, construct perform some actions on all the workers.

    I don't know which mechanic that is in play here and that is the problem.

    For example, if I have a boolean "ExtractWood"

    And then I have a condition like "If worker is ExtractWood"

    it should do certain actions.

    The problem is that Construct perform actions to other workers, even though they are not "ExtractWood"

    I may have other conditions as well, like sensing if the Worker are overlapping the correct resource, and so on...

    So lets say my worker have targeted a resource - it is on its way there - then arrives.

    Then a condition comes in to play when the worker are overlapping that specific resource.

    What we have now is a specific worker (alone) overlapping a specific sprite (resource).

    So if I have a condition that this specific worker, identified with a unique id - triggers when overlapping this specific resource.

    When I perform actions when these conditions are met - other workers also sometimes do the actions.

    Have I missed something here, on how the mechanics work in Construct 2. On how conditions are met, and actions are performed. What have I been missing? Any suggestions on what may be in conflict would be very helpful.

    You can do so much designing a game without any programming at all. There are basic functions and methods to achieve stuff that is common regardless of programming language or editor. That's exactly what I'm interested in to know more about but with some practical examples that I can try in Construct.

    This post is exactly what I'm talking about:

    ...and right now I'm interested in creating a finite-state-machine, and later implement that in Construct 2.

    And in the future start working on a Real Time Strategy game.

    -

    That's THE END of my little novel here Sorry if I've written too much.

    Regards!

    ///Soulmachine!

  • I like this Id�a :)

    I've made several other manoeuvres when I select and mouse over different things. The outline effect could be very useful, instead of making several animations on an object all the time - and or "invisible" sprites - for selecting...

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I got frustrated, and put my thoughts into words. For that I Apologize.

    I will not uninstall, cause I love this program, and have made lots of nice things with it.

    The Scirra guys, sounds like nice people, with good hearts. Very creative and excellent solutions.

    Most other sites have a captcha solution

    Not forcing people to build up reputation points.

    A lot of humans try, and try again with a problem to solve it before they ask for help. When they do, they need it. Its frustrating if you dial 911 and they say "We must make sure you are sincere, can you please build up some reputation points first."

    Some visual problems are hard to explain, and the first people ask for is a picture, or in this case when its a computer-program, that we are working with - they ask for a program file .capx

    You can wonder why, the reputation program exist. I do not think it is because of bots.

    It is better to be honest and speak the truth, than try to stretch the truth to mask the real intentions.

    If we should ban computers just because some people abuse them and let 100% of the rest of the world not use them. That's not fair, when there is so many other more logical solutions.

    It's better to turn the other cheek to the low percentage of abusers, just because its morally right. And the increase in labour to address some spam, can look lazy.

    3 times this has hindered me asking for help. And you guys probably knows how frustrating programming can be.

    I'm just a man that use words... Perhaps painting mental images, with the words, a bit too much. It's feelings, and I'm human.

    If I can feel it, others can too.

    So I'm helping you also feel, feel what your customers feel. Perhaps I've made you a dollar or two, planting some thoughts that will take shape in the future to something better than the present day.

    I wont apologize for my feelings, as I wont apologize that I like strawberry ice-cream more than chocolate ice-cream. Feelings are never wrong, even the most evil ones. Its what you do and act - that can be wrong. The choice you make when you have the feeling.

    No one can decide another persons favourite choice of ice-cream.

    I do apologize if I offended anyone by expressing my self so rudely. Cause I DID. And if this hurt their feelings. I want everybody to be happy, and I care a lot.

    Normally I'm the kindest ever, but I got upset.

    ///Soulmachine!

Soulmachine's avatar

Soulmachine

Member since 27 Oct, 2013

None one is following Soulmachine yet!

Connect with Soulmachine

Trophy Case

  • 11-Year Club
  • RTFM Read the fabulous manual
  • Email Verified

Progress

13/44
How to earn trophies