R0J0hound's Forum Posts

  • Ashley It only occurs when not using webgl. In the sprite plugin it has the function "preloadCanvas2D" that draws all the animation images to the canvas on load. You can see it in any project if you set "Enable WebGL" to off, "Clear Background" to no and make the bottom layer transparent. So when the load is quick you will never see them since it will be overdrawn.

  • You could try the canvas.rgbaAt(x,y) expession... or use the blueAt(), redAt() and greenAt() expressions to get the color components to build a color string like "rgb(0,255,255)".

  • The flood fill action seems to hang when there is transparency in the canvas being filled. Also the other color names work as I recall in Firefox. But in chrome they don't seem to be, but using color strings like "rgb(0,255,255)" do work.

  • One brute force way it could be done is have the computer simulate every possible game and build a tree graph of moves to different states of the board. Then once built each move could be rated by how close it is to a check mate. Then the cpu could just pick the move that would result in a win the quickest. A drawback of this is it's not really possible to do this as building the tree graph would be very time consuming and it would take much more memory than is available.

    You could instead look n moves ahead instead and choose moves that would lead to a win in n moves or less, but you'd run into the case where there is no win that close so you'd have to use FragFather's idea to have the cpu do better than just a random move. You wouldn't be able to look too far ahead though as the amount of board states to keep track of increases exponentially. Consider as a simplification that there are only 10 moves possible in any given board state. Then with 0 moves you'd have 1 board state to keep track of. With 1 moves 11 states, 2 moves 111 states... So at 9 moves ahead you'd have 1,111,111,111 states to keep track of or a least check for a win. That is over a billion moves and if will were able to store each board state in 64 bytes you'd be using over 64 gigs of memory. So the problem becomes finding some kind of shortcut to make the cpu make a descent decision within the limits of memory and cpu speed. Few would want to play against a computer that took event 10 seconds to make a move. There are shortcuts and simplifications that can be done such as only looking at the better moves per step instead of all of them. That would allow looking more moves away whist using less memory. Also less memory could be used if you only keep the board states as long as it's needed, and mainly keep a move list.

    One method that is used to pick a better move is called Minmax. Where the idea roughly is to minimize the player's score and maximize the cpu's score. For this we need to know if one board state is better than another. It's relatively easy to identify a checkmate as a win or lose, but for all the other states we need some kind of rating. One rating could be to sum up the values of the pieces of the board where say the black pieces are: pawn=1, ..king=5, and the white pieces are negative: pawn=-1... king=-5. So after a move if the score goes down then it's better for white and if it's positive it's better for black. For a minimum you'll want at least 2 moves so the opponent's response can be considered as well, and a move can be picked with the best end score.

    Another method is the Monte Carlo way. AKA a random set of moves is done and the end score is checked. Usually this is done many times and then only the best result is picked as a set of moves to go with. I imagine this will be haphazard at times but if a high number of iterations (times) is used the results will be better.

    Probably a mixture of the methods will be needed to make a good ai that doesn't take forever to decide on a move.

  • Poking around the source it seems to use the Titanium SDK as a base. Which was slow with C2 games last I heard:

  • The event sheet is run every frame so if the action is under a condition that is continually true the action will continually run. Perhaps try adding a "trigger once" condition, or if maybe you could put it under a "start of layout" condition. It really depends on what you're doing.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Referencing your first capx, before you press return there is one text2 object offscreen.

    When you press enter the first time another text2 object is created and 1 is added to it's paragraph variable. The first instance will still have a paragraph value of 0 since it wasn't picked when the add 1 action was run. It wasn't picked because when you create a text2 instance it becomes the only instance picked for the actions that follow.

    So now there are two instances of text2. One offscreen with a paragraph value of 0 and one on screen with a paragraph value of 1. Now after that when you press return a second time both of your events will run because one instance has a paragraph value of 0 and one has the value of 1.

    You could just move the text2 object instead of creating another and set it up like this:

    https://dl.dropboxusercontent.com/u/542 ... fixed.capx

    or this:

    https://dl.dropboxusercontent.com/u/542 ... ixed2.capx

    On a side note take a look at the 9patch object. With it you can reproduce the bigredtextbox object exactly using a much smaller image.

  • You could do this:

    Event:
    Repeat 4 times
    Pick instance with UID int(tokenat("0,1,2,3", loopindex, ","))
    
    Subevent:                                 
    Animation frame = 3
    
    Action:
    Set variable to 1[/code:15uf40zs]
  • Digging though my capx files I found a couple solutions.

    Here I did wall sliding that works best when the wall angle is 45 degrees from the angle of motion.

    viewtopic.php?f=147&t=91933&p=719471&hilit=event_motion2.capx#p719471

    And here I used SAT in one and used the custom movement behavior in the other to compare. The first is spot on perfect but the moving object is treated as being perfectly round and it only works with rectangular walls.

    viewtopic.php?f=147&t=95108&p=736233&hilit=slide3.capx#p736233

    Hope that helps.

    PS.

    SAT stands for the Separating Axis Theorem and basically gives more info about a collision such as penetration depth and closest direction to resolve the collision.

    EDIT:

    Another idea that is more like steering is to use two detector sprites attached to the moving sprite. Then when they overlap a wall one turns clockwise until it's not overlapping and the other turns counter-clockwise. The just set the angle of motion to whichever detector that turned less.

    https://dl.dropboxusercontent.com/u/542 ... steer.capx

  • One way I handle a situation like that is this:

    find("|1|4|5|6|7|9|11|12|", "|"&var&"|")<>-1[/code:3an99age]
  • I behavior is in the web browser's canvas, so I can't do anything about the issue as it is. The only idea that would work is looping over all the pixels in javascript to have more control, but it will be very slow since it would be done on the cpu instead of the gpu.

    So unless another creative solution is found the fastest way will probably be to use fading sprites.

  • When you preview it will show that, but when you export as nodeWebkit it will show the game path. As far as the path to your capx or project folder I don't think there is an expression for that. My guess is you'd have to type the path in manually when you're previewing and then change it over to the expression when you export.

  • Here is a capx with a few different methods:

    /examples22/cannon.capx

    https://www.dropbox.com/s/f651hqzv53u23 ... .capx?dl=1

    The first method uses a fixed speed and finds an angle. The angle is NaN if there is no solution.

    The second uses a fixed angle and finds a speed. The angle is NaN if there is no solution.

    The third is like the second but the angle is always pointed above the target so there always is a solution.

    Finally the bullet behavior wasn't used since the path isn't accurate when using gravity.

  • NodeWebkit plugin with the NodeWebkit.AppFolder expression.