Lncredible's Forum Posts

  • Hi there,

    I am not quite sure what you mean, and I don't know what Behaviour you are using (Bullet?), but perhaps you could try the following action:

    Event - Plane hits edge of layout

    -- Action - PLANE: Set Mirrored

    -- Action - PLANE:BULLET: Set Bullet angle of motion 0, or 180, depending on which direction you want it to go next.

    If the plane is only travelling Left or Right then he can be Mirrored. You might need to disable "Set Angle" on the Object under the Bullet behaviour settings otherwise it will always set the animation to the angle of motion. If you aren't using the Bullet behaviour then Mirroring should work fine without any other adjustments.

  • Hi there,

    I have been changing my fonts from the built-in Spritefont plugin to Spritefont+ (https://spritefontplus.codeplex.com/) so that I can quickly set character widths using JSON.

    In the property of the Spritefont+ objects you can CLEARLY set text alignment, but my issue is that I want to do this with an event-action. I.e:

    Start of layout

    • Spawn Spritefont+ object at x,y
    • Set Spritefont+ object horizontal alignment to RIGHT

    But the actions don't seem to exist. Has anyone else had this issue?

  • Hmm, normally I would expect the row to come first, then the column. This would also enable you to work with "For each X" instead of "For each XY".

    A faster solution without a loop would be:

    Player carries an instance variable of where is saved in the array. (if elements will be removed from the array at some point, you need to update the positions in those cases, though)

    then you could: "Levelup" (Parameters: player.arrayposition, parameter_num, value_to_add)

    on "LevelUp":

    set array at (player.arrayposition, parameter_num) to array.at(player.arrayposition, parameter_num) + value_to_add

    Obviously you need to switch x and y, if you want to use x for columns and y for rows.

    Thanks for your help. I will take note of this and try to adjust my code.

    I found out what the issue was with my particular example - I was using a plugin "CSVtoArray" to import my data and it converts every single entry in the Array to "Text" so even numbers are not classed as "Number". I re-worked my code above so that my local variable was a text object (for searching the array) and now it works.

  • Hi all,

    I store all my "player data" in an array called Player.Array. When a value changes I want to be able to write data back into my Array, editing fields such as "Strength" or "Agility" immediately when a player levels up, for example. The benefit of this is that when the instance is destroyed he won't lose his stats.

    Player.Array:

    ID,NAME,CLASS,STR,AGI,INT

    0,Dingle,Mage,3,5,9

    1,Muscle,Warrior,9,6,1

    2,Flight,Druid,6,6,3

    3,Joseph,Bard,5,5,7

    4,Stars,Druid,5,4,6

    Here is my current method (not working) for editing data.

    Scenario: "Flight" levels up and chooses a point in Intelligence. I need to search the Array for his ID number (2) and then Add 1 to his Intelligence column.

    On Function "LevelUp" (param(0)) ## Function is called with the UID of the character who levelled up.
    Local number Array_Looper = 0 ## To loop through the Array incrementally.
    Local number Player_Finder = 0 ## To grab the UID from the instance to look up in the Array.
    
    [ul]
    	[li]Set Array_Looper to 0[/li]
    	[li]Set Player_Finder to 0[/li]
    [/ul]
    Pick instance of Player with UID Function.Param(0) - Set Player_Finder to Player.Player_ID ## An Instance variable that stores ID from Array on the instance when it is spawned into the game.
    
    For each XY element in Player.Array:
    If Player.Array Value at (0,Array_Looper) = Player_Finder - Set value at (5,Array_Looper) to Player.Array.At(5,Array_Looper)+1)
    
    [ul]
    	[li]Add 1 to Array_Looper[/code:22ce4qg8][/li]
    [/ul]
    So I have done a few tests and not come up with much. The annoying thing is that this code works elsewhere in the same project. I more or less mirrored it and changed the details, but I guess that's where inconsistency sneaks in.
    
    Any help would be much appreciated. I'll try any suggestions in a new project tomorrow just to get away from a very busy load of code and try some ideas out on a blank canvas...
  • Hi all,

    I am trying to find the best of way of handling combat in a tank-based game where most of the combatants are NPC AI who drive about shooting one another using the pathfinding module and line of sight.

    I have come up against a problem handling the fact that both objects have "LINE OF SIGHT". Let's call them Team1 (red tanks) and Team2 (blue tanks). What I have been so far is this:

    Team1 is within line of sight of Team2

    Pick Instance 0 of Team1

    Set Team1.InCombat = 1

    Pick Instance 0 of Team2

    Set Team2.InCombat = 1

    .........

    Team2 is within line of sight of Team1

    Pick Instance 0 of Team1

    Set Team1.InCombat = 2

    Pick Instance 0 of Team2

    Set Team2.InCombat = 2

    .......

    As you can see I am trying to identify which set of code to run based on whether Team1 saw Team2 first, or Team2 saw Team1 first. Is this how I should be handling it?

    Things get more complicated from here. Basically I want to be able to have multiple tanks in combat with each other at the same time using the same mechanics as above, but I'll summarise my intent:

    1) Tanks enter combat by driving around until they come within line of sight of eachother.

    2) Regardless of who saw who first, the two tanks enter combat with eachother until it is resolved.

    3) First step of combat is to turn and face one another

    4) Only when they pointing directly at each other can they start firing (this can mean that one tank can start firing before the other as it reaches angle(x,y,x1,y1) (or indeed [angle(x,y,x1,y1) -180]) first.

    5) When one tank is destroyed the order needs to be given to the victorious tank (or tanks) to continue pathfinding. I am having most trouble here when multiple tanks are engaged in a fight with only one example of a tank.

    Most of my mockups end with two or more tanks entering combat with one. When combat is resolved (let's say Team1 won) the victorious Team1.instance1 deals with its own pathfinding and drives off, leaving Team1.instance2 sitting there because I have failed to keep track of the UIDs of who was in a battle.

    Can someone explain the best method of handling multiple instances like this? I want 2on1 or even 3on1 battles to be a possibility, but I can't believe that the best way to do this is to keep copy pasting my code and putting in "Pick instance 0" "pick instance 1" "pick instance 2". How would you even go about handling 50-100 instances individually?

    Thanks for your help.

    Lncredible

  • Actually, using the dictionary object would be perfect for this..

    Oh my.. There's a dictionary object?... I think I have been "thinking around the problem" and overlooked something major...

  • Hi all,

    I want to create an auto-runner that uses real words to influence terrain generation. My idea is to create pieces of the environment using only ONE Sprite that has 26 frames (representing the entire pool of the English alphabet).

    Example:

    The word "CARS" is selected and stored in an Array. The game will loop through the array spawning instances of "Sprite" and setting the frame to the equivalent number in alphabet (-1).

    "CARS"

    For 1 to TotalLettersInWord

    -> Spawn Sprite at XY

    -> Set Frame to WordArray[CurrentLetter]

    -> Add 1 to CurrentLetter

    All sprites will be moving to the Left with behaviour "Destroy outside of layout"

    Once the last letter has been spawned it goes back to the first letter, looping indefinitely (another part of the game will change the word).

    I am using this method because I think it will be an interesting way to create patterns within the game's landscapes based on the patterns in word construction in the English language, i.e., vowels are only used after certain letters, and certain combinations NEVER come up, such as X followed by R.

    SO MY QUESTION IS - What is the best method of creating a list / table of words that the game chooses from? I want to be able to sort them by character length, but other than that I could practically include a whole dictionary as long as it wouldn't slow the game down to a crawl. Any ideas?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Crossworks performs much better than Cordova

    Hi,

    Only option I have is to export with cordova - was Crosswalk a few versions ago? how else can I do it?

  • Hi there,

    I am exporting my project using Cordova and then using intel XDK to create an APK. I test my game regularly on my OnePlusOne and Nexus 4 and they both have around 50 - 60 FPS. I sent my game to a friend, however, who is using a Samsung Galaxy S3 and the game runs at 3 FPS! The real frustration is that, a few months ago, the game worked at around 40-50 FPS on the same Galaxy S3 and if anything I've made huge improvements to performance since then.

    Have you any suggestions?

    Thanks!

  • Are you checking the collision with all the blocks in the game?

    Usually I create a turning point for the enemy using a invisible block, so the turning will be triggered on collision instead of checking collision every tick.

    Hope it helps.

    Hey! thanks for replying.

    The problem is that the enemy can end up anywhere on the map (he can fall through part of the world but must still keep moving). I too have used invisible blocks to do "left right" before, but these enemies must continue where-ever they go within the destructible blocks, and must be able to collide with any of them if it hits them.

  • Hi there,

    I have an *Enemy* in my game that moves Left and Right with the default Platform behaviour, with an instance variable the toggles in the code.

    -> When var "LEFT" = 1

    -> Simulate control moving left

    -> When var "RIGHT" = 1

    -> Simulate control moving right

    I am assuming that these both run at 60 times a second as default. The behaviour of the enemy is that he should keep running LEFT until he hits a *Block* then he goes RIGHT. Here's where it gets intensive - there are usually about 50 - 200 blocks in the game at any one time, so if he's always checking collision with *Block* it generates "60*#ofBlocks" collision checks per second, per *Enemy*.

    Is there a better way of checking collision so that it doesn't swamp my game down whenever these enemies are put in?

    P.S. - *Enemy* is 128 pixels wide. Would checking his X - 64, X + 64 for an instance of block work better?

  • yeh, it's gonna be nice removing all this clutter from around the edges and the unnecessary "destroy when outside of layout" to get rid of some of them...

    Thanks for your help.

  • Best method:

    Put all your sprites and objects you do not want to be on the layout on layout start, in a dedicated layout for that.

    near ALL my projects have a "Objects" layout. In which I stuff and prepare all my sprites.

    And create/spawn the objects you need on the layout you want to run.

    So yes, the "Object Store" is a very very good method.

    Great. Do you need to explicitly start with the Object Store and immediately "on start of layout" move to the first intended layer?

  • OK, good suggestion. So in any layout following the first I can have a clean sheet to work from and it'll keep the data loaded from Layout1?

  • My game has a layout per level, but I noticed you only have to store objects in one layout for them to be usable in every layout... MY question is... Can I have one dedicated layout (that is never used) as an "object store" with all the usable objects in it that aren't part of the level-layout specificallys? (created by event instead).