impact's Forum Posts

  • 14 posts
  • Oh, totally sorry - was my fault. I created my Player-Object in the wrong line (before the loop that actually determines how many players there are).

    Yeah, I've been working 24hours straight on this now. I should take a break.

    Thanks for the help though

  • Hello,

    another picking question from me.

    In my event sheet, I have a section "Setup", where there are several "Start of Layout"-events.

    One of them is setting up the gameworld, creating planets at random positions, then going through all the players and picking a random planet for them to have as homeworld.

    At a later stage, I trigger a an event "Every 1000 milliseconds", where I try to go through all the planets and update their gamestate. However, it seems that the script only picks a single planet: the one that's been last picked by the setup event (the homeworld of the last player added to the game in this case).

    Is there a way for me to manually tell Construct to forget about previously picked objects and start picking from scratch?

  • Ah, thanks. That's awesome

  • Hello,

    I still seem to get a bit confused about some of Construct's inner workings. Maybe you guys can help me out a bit.

    I have a family "Ships". I want to pick all ships that have their private variable "status" set to "Engaged" and then run several checks and actions on them.

    Does it work like this?

    Pick Ships by comparison: Ships('status') = "Engaged"
      Move to Enemy...
    [/code:l4jytlz0]
    
    or do I have to do it like this:
    
    [code:l4jytlz0]
    Pick Ships by comparison: Ships('status') = "Engaged"
      For each Ships
        Move to Enemy...
    [/code:l4jytlz0]
    
    Meaning: When I "Pick object by comparison", does it loop through all objects picked automatically within that event, or do I have to do the "For each object" to loop through them?
    And: Does the For each then loop through all the Ships, or just the ones I filtered through picking in the parent event?
  • Hi,

    how about an import/export function for event sheets?

    Would make it easier to back important code up or implement it in other projects.

  • I tried to reproduce it in a fresh project, but it doesn't give me the same problems. However, there is either something wrong, or I just don't know how to work this.

    What I did is this:

    I created two sprites - a red ball and a blue one. Red one is called "Fighter", blue one is "Bomber".

    I added them to the families "Ships" and "Selectables".

    I added RTS, LOS and Turret behaviour. I opened the event editor and added these events:

    Ships[LOS] -> On Object in LOS (Selectables)
       Ships[Turret] -> Acquire Target
    
    Ships[Turret] -> has target
       Start Flashing
    
    Ships[RTS] -> not moving
       Ships[RTS] -> Move to Position (Random(DisplayWidth), Random(DisplayHeight)
    [/code:2tpzwvl7]
    
    That worked as intended.
    When I removed LOS and Turret behavior from the fighter, they automatically got removed from the families, which is as it should be.
    However, the last event stopped working - it's still there and it hasn't changed at all, but both sprites don't move as they did before.
    I re-added the events for the turret and for LOS, but instead of "Ships" I just used "Bomber", as it still has those behaviors. Nothing. Complete standstill.
    Maybe I am doing something wrong, maybe I'm just tired, I don't know.
    Anyway, here it is.
    
    [url]http://www.thecursed.net/behaviour%20bug.cap[/url]
    
    Should I still submit it?
  • I wouldn't use "for each" for going through larger families. Instead try "Pick object by value", where the object would be your family. It will pick all objects the expression you enter applies to.

    I did a little speed test for that - in my project I have the family "Ships".

    I displayed an object counter in my debug console and told Construct to create fighters (member of ships) until the fps drops below 60.

    In my code I did:

    for each (Ships)
       Ships('status') = "Idle"
          Tell ships to move to random position
          Set Ships('status') = "Roaming"
    [/code:3q3mibjp]
    
    My object count went up to close to 1.600 before my FPS dropped below 60.
    However, when I tried this:
    
    Pick (Ships) by value 'Status' = "Idle"
    etc.
    
    My object count went up to close to 16.000 before my FPS dropped below 60.
    So this is clearly faster.
  • Hello,

    I am saddened to say that it seems that my project just died

    I had a family called "Ships". That family contained two sprites: "Fighter" and "Bomber".

    Both sprites were also part of the family "Selectable Objects".

    During the development process, I experimented with behaviors a little bit to see what could be achieved, so both sprites had the "RTS", "Turret" and "Line of Sight" behaviors.

    When I selected my Fighter-Sprite and removed the "Turret" and "LOS" behaviors, because I didn't need them anymore, my project wouldn't run anymore.

    When trying to preview it, it would tell me: "Behavior name: 'Turret' not found".

    Now, I know that some might think that the problem lies in my event sheets buried somewhere, but my code is very well organized. Everything is stored and ordered into certain groups. Even deactivating all groups but "Setup", where he sets the screen resolution, would give me that error.

    I tried moving families around, I tried adding the behaviors again (when adding just "Turret" but not "LOS", it would tell me he couldn't find the behavior "RTS", which is CLEARLY a bug, so I had to re-add "LOS" too).

    When "Turret" and "LOS" were added again, my project would run, but all private variables for the families affected were "Read Only", meaning I could read them out in my debug console, but couldn't change them anymore, even though I checked during runtime that the correct events were triggered. This means for example:

    Pick all Ships where 'status' = "Idle"

    Set Ships('status') = "Roaming"

    Debug.Text = Debug & "Status should have been set here"

    And yes, I got the text on my debug console. However, the ships were still set to idle.

    I guess there is no hope but to start from scratch now?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • This was exactly my question, thanks

    I wasn't sure if once you picked a set of objects by saying

    Select all structures where faction = "Blue"

    the next picking of object (pick object closest to...) would take place in that already picked set of objects or in a fresh, unfiltered set of all objects in the family

  • Thanks for your reply.

    I don't want to pick the blue member closest to my mouse, I want to pick the blue member closest to my mouse that is a structure.

    It would look like this:

    For all Structures in Blue Player

    Pick object closest to X/Y (MouseX, MouseY)

    Just that I don't think Construct supports something like that without using arrays. However, using arrays for this just feels...dirty. I was looking for a more elegant way to handle it.

  • Hello,

    I am not sure about this, maybe I am just tired, but I have a problem:

    I have one family for each player (Red Player, Blue Player, etc.). Those families hold all structures and units in my game.

    Now, I have separate families for those as well (Units for my units and Structures for my structures).

    What I need to do is this:

    Get the coordinates of my mouse cursor (I know, MouseX and MouseY) and see what friendly structure is closest to it.

    For example:

    I am the blue player, my cursor is closest to a red structure. However, this is not the one I want to pick in my game code. I want to ignore all structures but the blue ones and there pick the closest one.

    The way I see it, my only means of doing so would be to split the player families further, so that in addition to Units, Structures and Blue Player I would get Blue Structures and Blue Units.

    If at all possible, I would like to prevent that for sanity's sake.

    Any ideas? Maybe something I just overlooked?

    Cheers,

    Sebastian

  • I didn't very much, because I was still trying to get the hang of Construct. I wasn't sure how far I could go without it hitting me with exceptions. How far does it go? Do you use int or long int for the coordinates?

  • Hi, I have a theory that might be interesting - especially for those of you who are thinking about RTS-Games.

    What always bugged me when playing them or looking at engines was that they were so limited! Most RTS-Games today are hardly RTS at all, but more about tactics than strategy (yes, there is a difference ).

    So, what I am striving to do is creating a sandbox-RTS and virtually "eliminating" limits for unit count and map sizes.

    This theory is about the latter.

    For the sake of clearing things up, we will use a top-down space RTS as an example.

    Usually Construct limits you to using Layouts. You can make them pretty big (ie. 20.000 x 20.000), but when flying around in a fighter, even those can get pretty small after a while.

    Sure, you can use more than one layout, allowing the player to switch between them, but that has several drawbacks:

    1. Changing layouts means having to load a new one. Depending on your machine, the size of the layout and the textures the game uses, this can take a few moments.

    2. When being promised a world to conquer, it would actually be nice to HAVE a world to conquer and not just a simple set of regions. Moving seamlessly in a game, especially through large areas, is an amazing experience for every gamer that shouldn't be underestimated! =)

    So, here comes the theory:

    We can create a virtually "unlimited" game area by abandoning the built-in scrolling on layouts and instead let the game "scroll" around us. To do so, we would need an Array that holds the environment of our game.

    Let's say you have a "Player"-Object which initializes in the center of your screen, has the "Center Screen"-attribute checked (so we cannot scroll away from it) and has opacity set to 0% (why would we want to see a player-sprite in an RTS-game?). In that sprite we store the private variables mapX and mapY, which will be our "virtual" coordinates in the gameworld.

    Alternatively you can leave the sprite and use global variables instead.

    What we now want to do is: When the player presses any of the direction-keys, we want to "scroll" there, without actually scrolling on the layout. Instead however, we scroll through the array, which holds the positions of every game object, and we check the array-coordinates against width and height of our layout to see if any objects enter or leave our viewport.

    Now, those of you who used arrays for any mapping purposes already, might be tempted to use the array like this:

    array( x-coordinate, y-coordinate, property-index )

    That however would defeat the purpose - if we stored game-objects like this, our array would look something like that:

    array( 1, 1, 1 ) = ""

    array( 1, 2, 1 ) = ""

    array( 1, 3, 1 ) = ""

    array( 2, 1, 1 ) = Ship.UID

    ...

    What you can see at first glance is that three out of the four elements I was showing you are empty!

    Considering that with every tick, we have to go trough each element of the array, check it for existance and then handle it with our game mechanics, this technique unneccessarily eats up memory and cpu-time!

    Instead the array we are going to use should look like this:

    array( list-index, property-index )

    Resulting in something like this:

    array( 1, 1 ) = "2032" // x-coordinate of the object

    array( 1, 2 ) = "1060" // y-coordinate of the object

    array( 1, 3 ) = "42" // UID of the object

    This would eliminate the need to go through empty elements, allowing us to store more actual in-game objects in the array and saving us precious cpu-time when scanning through it.

    So now, whenever the player scrolls, his REAL position on the layout stays fixed. Instead, we change the mapX and mapY coordinates accordingly and scan through our array to see if any objects appear or disappear.

    The latter should be done every tick, by the way - objects like ships and other units are supposed to be able to move, so their coordinates will change and they might show up on screen even if the player isn't scrolling.

    So, with every tick we go through the array and look at the coordinates for each object we stored there. If it is on screen (x > mapX - DisplayWidth, x < mapX + Displaywidth, y > mapY - DisplayHeight, y < mapY - DisplayHeight), we will show it. If it is off screen, we either won't show it or hide it if it was shown until now.

    Alternatively you could have two arrays with identical structure, one holding objects currently shown, one holding objects that are off screen and then move array elements back and forth as objects go on and off screen. That way you would have to scroll through two arrays (which shouldn't make much of a difference, considering it's still the same number of objects), but it would probably clean up your code a little bit. Also this would allow you to perform actions that are limited to objects on screen more easily, as you wouldn't have to sort through one large array, but you could just check the array with the on-screen-objects.

    Also you might want to think about adding a threshold of some kind to the above equation.

    Why? Imagine you have a ship, especially a big one like a carrier of some kind. It is about to go on screen. Our array stores the position of objects - in case of sprites that would usually be the center (so sprite.width / 2, sprite.height / 2). This means when said ship is determined as "on screen" by the above formula, one half of it actually already is, thus making it suddenly "pop up". We don't want that, so we have to add the height and width of the sprite to the equation above, or create a general threshold where we start showing objects, even though the player won't see them yet but is about to.

    So, this is how I would do it. However, this presents us with a number of questions and problems.

    1. What do we ACTUALLY do when making objects appear and disappear as they enter and leave the screen?

    We could create and destroy them. But that presents us with the problem that we don't have access to their privates variables and that the sensitive data in those variables would be lost as soon as they left screen. This is a big deal, especially when it comes to information like hitpoints, as you can imagine.

    We could make them visible and turn them invisible if they left the screen. The problem with that is: when you want to use this technique in your game, it usually means you want to make a game with a HUGE scope where you can do all sorts of things. So this probably means that you want to have a lot of objects in it too, otherwise why use unlimited game areas in the first place if it only means lots and lots of empty space? So, by switching the visibility of objects, we keep them in memory ALL THE TIME! Think 20 Carriers, 60 Destroyers, 500 Fighters and maybe lots of other ships in an early(!) gamestate and imagine how totally not smooth the game will start to behave.

    An alternative could be the first method - creating and destroying objects as they go on and off screen. We would have to stop using private variables though and use our array to store object-related data. This means however that everytime we want to access this data, we have to scan through the array and find the UID of the object we would like to deal with.

    2. How do we handle off-screen events?

    Let's say you think about attacking and taking this planet. Your fleet is standing by and you finally give the command to attack. Your ships approach the enemy planet and suddenly you realize that you have to go elsewhere - maybe to build something, maybe because you are being attacked somewhere. As you scroll through the map, the game will determine your ships as being "off screen" at some point. And what happens then? Even when they are off-screen, they are supposed to be moving towards that planet and at some point start firing on enemy ships (which means spawning lots and lots of bullets, that we ALSO have to store in our array).

    If until now you thought the size of those arrays would be managable, imagine 200 ships spamming the battlefield with laserfire and think about the number of projectiles this would produce per SECOND. Every single one being an entry in your array, of course. An entry you check for visibility and changes of object-dependant variables every single tick(!).

    I personally see only one way to solve this problem: while you update the positions of each object in the array every tick, no matter if they are on screen or not, you don't let them actually DO anything else while they are off screen, but instead calculate what happens there.

    That means our attacking fleet wouldn't spawn bullets, wouldnt even really attack while they are off screen. But the system would realize the AI is engaged there, pick targets and calculate how much damage who takes when.

    So, you can see after this incredibly long text that there are a lot of problems with this technique. The questions are: do you see more? How would you solve them? Do you think such a feature is worth all the trouble?

    Anyway, I will be waiting to hear what you think about this very eagerly, and thank you for taking the time of reading this wall of text

    Cheers,

    Sebastian

  • Hey everybody,

    I am Sebastian, I live in Hannover (Germany) and I found out about construct when I was googleing for an Open-Source RTS-Engine about a week ago.

    Ever since then, I have been glued to my screen, experimenting with stuff and I must say: rarely in my life have I been so hyped!

    But before we come to that, a little bit about me:

    I am currently 28 years old and I've been working as a professional software developer since 2000.

    Personally I have a long history with computers and programming - first time I wrote my name as a child was when cracking the high score of some shooter-game on the C64

    My father used to work for IBM and then started his own business, repairing computers and typewriters from home, so I pretty much grew up surrounded by all those machines. And my fathers apprentice soon tought me my first lines of basic. Ever since then I wanted to be a game programmer.

    However, starting out in the industry is not easy - with limited internet access back then and hard-to-find information about Windows Programming, I decided to take on an apprenticeship myself. I started out as a database developer with MySQL, MS-SQL and Microsoft Visual Foxpro. After that I went into developing intranet-applications with PHP and MySQL.

    With my goal of learning C++ and starting game programming nowhere near, I was let go in 2004 during one of the IT-Bubble-Bursts. Since then I've returned to school and went to university, working as web-developer and in IT-Support every now and then.

    Currently I study IT at the University of Hannover, but as I don't get younger and university becomes too expensive for me, I started getting my head into C++ several weeks ago.

    Construct is the perfect opportunity for me to learn more about game programming, realizing my own creative ideas and hopefully one day find my way into the industry.

    So, that was a lot.

    Sorry if I rambled, but for the past few days you guys have been such a big help for me, the least I can do is tell you who I am.

    Hopefully, we will see a lot of each others on the forums from now on

    Cheers,

    Sebastian

  • 14 posts