R0J0hound's Recent Forum Activity

  • I often use for each ordered to do that. Here it would shoot at the 3rd closet. This method is also useful when you want to do stuff with the n closest like it sounds like you are.

    For each enemy ordered by distance(player.x,player.y,enemy.x,enemy.y)ascending
    Loopindex+1=3
    — stop loop
    — shoot
  • I like that kind of problem.

    One idea is a rough LOS check. Basically repeatedly pick a random point inside the collision poly a do a LOS with that. Would fail more with smaller loops if the object is obstructed but it may give a true eventually. Could be a useful approximation of vision. Anyways the main sub problem to solve would be to get a random point in a polygon.

    A second idea is to utilize raycasts. Either a uniform spread of rays in roughly the direction of the object or use a bit of random. If any of the rays hit, there is LOS. I think this one is the most doable. Not sure if the ray cast feature in c3 can be used for this but making a ray cast with events would work.

    Another idea if to calculate the view polygon from one point and check to see if that view poly overlaps an objects collision poly. May be tricky to calculate though. One approach would be to do what shadow casting does and clip away from the collision poly the shadow bits. This would give an absolute is in in Los or not check.

    Anyways just some ideas, each with their own set of sub problems to solve. Maybe some are useful.

  • Since they are all trees you could just make them all one type and use different frames or animations to look like the various trees. That would save on events.

    For the random id go for something like this which would make each tree at closest 0.5 sec apart.

    Var next=0
    
    Next<time
    — set next to time+random(0.5,5)
    — spawn tree
    — tree: set frame to int(random(5))
  • Here's a rough demo of iso. I'm poor at ripping/creating art but it gets the point across.

    dropbox.com/s/7pz214ogx58jzz0/sokoban_like_iso.capx

  • I've gotten that error when trying to open a c3p file saved with a newer version of c3 than I have open.

    If that isn't it then you can open the c3p file with a zip program as it's just a zip file. If a zip program can't open it then it may be corrupted.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • There are many ways to do that.

    One is to just use the touch location when you tap. Use it with a non scrolling layer. You can subtract the center of the screen to make it so tapping the center of the screen centers the view.

    touch.x-screenwidth/2, touch.y-screenheight/2

    Another is to change the rotation values based on how far you drag.

    Roughly this. You'd want to get touch coordinates from a non 3d layer.

    var rotx=0
    var roty=0
    var oldx=0
    var oldy=0
    
    on touch
    -- set oldx to touch.x
    -- set oldy to touch.y
    
    is touching
    -- add touch.x-oldx to rotx
    -- add touch.y-oldy to roty
    -- set rotation to rotx, roty
    -- set oldx to touch.x
    -- set oldy to touch.y

    At least that's something to try. You may run into gimbal lock or rotation in a non desirable way but it depends on what you're doing.

    Worst case I'd do the rotation math directly with a 3x3 matrix and apply that with the look at action. It would give the most control of how you rotate. Like instead of the arbitrary euler angles like when you set the rotation you can rotate by any axis such as one relative to the screen. But I may be overthinking it.

  • I don't have any third party addons so I can't open your capx but here is one way to have a scrollable area with scrollbars and hand pan. It clamps to the Scrollwindow to the scrollArea but the scrollwindow has to be smaller than the scrollarea.

    dropbox.com/s/qshp8w4mmp1jzro/scroll_area.capx

    In concept you can have multiple scrollable areas. One per window, but the capx would need modifying to handle that.

  • What you can do is check if the sprite is overlapping the grey area, and if it is then just reposition it to a new random position.

    Here's one way to do it, but the sprites may be in the grey area for a few frames sometimes.

    every 5 seconds
    -- create sprite at random(640), random(480)
    
    sprite: overlaps grey
    -- sprite: set position to random(640), random(480)

    Alternately you can do this to do it when the object is created. I used -- to indicate sub events.

    every 5 seconds
    -- create sprite at random(640), random(480)
    -- while
    -- sprite: overlaps grey
    -- -- sprite: set position to random(640), random(480)

    Or you could do this to not use sub events at all. It comes out the same.

    every 5 seconds
    -- create sprite at random(640), random(480)
    
    sprite: on created
    while
    sprite: overlaps grey
    -- sprite: set position to random(640), random(480)
  • Are you just wanting to be able to push things around?

    This works. Just change dx,dy and it should work for isometric too. The logic is it checks xy positions along the line by dx,dy steps. If it's a movable object, it is marked. If a wall or free spot is hit it stops the loop. And finally if it stopped on a free spot it moves the player and any marked movable objects

    dropbox.com/s/ayiduh75dimcxcn/sokoban_like.capx

    Edit: smooth motion idea.

    dropbox.com/s/l5f80pnz93658u8/sokoban_like_smooth.capx

  • One idea is to record the state of everything into an array and use that to play it back for the demo.

    Here’s an example with just one object. Could be a start.

    construct.net/en/forum/construct-2/how-do-i-18/replay-meatboy-55099

    Another idea is to just record the player input in an array. This is likely what those old arcade games did, but the frame rate was fixed. With construct the frame rate is variable. Even at 60fps each frame can vary a tiny bit which can throw off the reply.

    A solution to that is to make your game logic run at a fixed rate. However that can be complicated since events and behaviors aren’t made to do that.

  • It doesn’t work because everything within quotes is just text and not an expression. So what’s happening is basically int(“object.x”), and when text is converted to a number it becomes 0 if no digits were found.

    Maybe you meant to build the text you saved to the dictionary.

    “Smoke=“&object.x&”,”&object.y

  • The rot instance variable is the rotation. Flipped it would be 180, but I just have it rotating continually with "add 100*dt to rot". You can set rot in any way you like. Maybe using some easing or something like that.

    One way is to add another instance variable rotVel=-90. Then "set rot to clamp(self.rot+self.rotVel*dt, 0, 180)".

    On card click

    -- set rotVal to -self.rotVal

    It's done when rot=0 or 180.

    Just an idea.