R0J0hound's Recent Forum Activity

  • %or mod has no standard behavior across programming languages. Some, like js, will will keep the sign of the original number, and some will wrap around 0 to the positive number. Which I think would be more useful.

    Anyways since angle() gives an angle -180 to 180 you can convert it to the 0-360 range with

    (a%360+360)%360

    /// the second % is to get it back into the 0-360 range.

    Or

    A<0?360+A:A

    Alternately you could use the angle conditions or the angleDiff expression to check your angles. They can be helpful especially when you have to deal with the 0-360 seam

  • I'd imagine you could do it by setting the position and angles to each other and just using the move at angle action?

    I think you meant to use multiply instead of divide in that formula to find a point from another one.

    I only use the free version so I can't use too many layers, but here's another idea to do the masking with distort meshes and it just works with any angle.

    dropbox.com/scl/fi/big4tehj919tkonckmj3l/whackamole.c3p

    For the motion I'm using a spring which can be done with three variables and two actions:

    add 0.05*(self.goal-self.t)/dt-0.16*Self.vt to vt
    add vt*dt to t

    The first number is the spring stiffness from 0 to 1.

    and the second is the damping from 0 to 1.

    I tuned it so it overshoots the goal a few times, but if the damping is increased it won't do that.

  • I'm bad at fixing other people's projects.

    Here's the idea using that math to rotate a sprite around any point. Here I used ox,oy instead of dx,dy, but it doesn't matter. One stands for origin the other delta. Anyways think of it as just an image point you can change and rotate around. It's in the range of 0 to 1 but you can use a value like x/width to specify position just like in the image editor.

    dropbox.com/scl/fi/toop24j18hlfyc46isfyq/rotate_custom_center.capx

    Honestly you can avoid much of the math if you set the drawingCanvas's origin to be centered and center it over the piece you are creating.

    Wackytoaster's way is probably the easiest way to make an object that breaks apart. Take the image, make the pieces, assemble them to calculate the offsets, and when you create the pieces you use those offsets. You can shape the pieces any way you want. I guess using distort meshes or drawingCanvas to mask out the pieces would make it easier to work with multiple images. Also dynamic piece shape and size could be possible with some work.

    dropbox.com/scl/fi/e5ozclhdtvjm1at8mwxcx/explosion.capx

    Anyways just some ideas and experiments.

  • You can rotate an object around any point with

    Rotate a degrees clockwise

    Set position to (x-cx)*cos(a)-(y-cy)*sin(a)+cx, (x-cx)*sin(a)+(y-cy)*cos(a)+cy

    Where x,y is the point, cx,cy is the center, and a is the degrees to rotate by.

    So one possible solution could be to keep track of an offset dx,dy from the object’s xy to rotate around. Initially you’d set that to wherever on the layout minus the sprites position. Then after that you’d update it with a helper function.

    Number rx=0
    Number ry=0
    
    Function vrotate(x,y,a)
    — set rx to x*cos(a)-y*sin(a)
    — set ry to x*sin(a)+y*cos(a)
    
    Function rotateSprite(u, a)
    Pick sprite by uid u
    — sprite: set position to self.x+self.dx, self.y+self.dy
    — sprite: rotate a degrees clockwise
    — call vrotate(sprite.dx, sprite.dy, a)
    — sprite: set dx to rx
    — sprite: set dy to ry
    — sprite: set position to self.x-self.dx, self.y-self.dy

    Alternatively a different approach could be to have dx,dy be values from 0-1 to specify a point within the objects quad. Then to use that as a center you’d set the angle between two set position actions. It basically undoes the offset, rotates, then moves by updated offset.

    Set position to Self.x-(Self.dx*self.width*cos(self.angle)-self.dy*self.height*sin(self.angle)), Self.y-(Self.dx*self.width*sin(self.angle)+self.dy*self.height*cos(self.angle))
    Set angle to anything
    Set position to Self.x+(Self.dx*self.width*cos(self.angle)-self.dy*self.height*sin(self.angle)), Self.y+(Self.dx*self.width*sin(self.angle)+self.dy*self.height*cos(self.angle))

    Either way you need to change angle via events. Can’t use with a behavior that changes the angle.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Here's one solution just that creates sprites covering horizontal and vertical runs of the same tile. Used an array to mark tiles that were already used.

    dropbox.com/scl/fi/l78tvqp8lz6oyo7fojcck/runs_of_tilemap_tiles.capx

  • The canvas is rotating around the top left corner. You can change that in the properties to be centered, but you’d also need to move it by half the width and height when positioning it.

  • Easiest would be to only use obj files with uvs. If I was still working on the plugin I would just add 0,0 for missing uvs and improve the obj loader to give more understandable errors.

    Currently the plugin is on the back burner indefinitely. It is in need of a rewrite and the event system makes things more complicated than they need to be. And finally time and interest isn’t really there at the moment.

  • I see, like I said I’ve no idea about that game. Guess you could make the player move through the doorway when they hit it, delete those doors and seal up that way. But that’s something to fiddle with another day.

    In general it’s possible to do anything. You just have to break the problem up into multiple simpler doable steps.

  • You should be able to treat the 2d array as a 1d one. If 0 means empty do:

    on function “shiftArray”
    Repeat 16*16-1 times
    Array: at (loopindex%16, int(loopindex/16)) =0
    — array: set at (loopindex%16, int(loopindex/16)) to Array.at((loopindex+1)%16, int((loopindex+1)/16))
    — array: set at ((loopindex+1)%16, int((loopindex+1)/16)) to 0

    So the process would be to 1st set the array location to 0 that you’d want to delete and then run that to shift. It only shifts by one space so if you delete multiple then you have to run that the same number of times.

    I’m assuming the array starts fully shifted but if it isn’t there is a way to modify it to do that. Or a brute force way to do it is to just run the function 256 times.

  • The top one has to do with the order things are drawn. In 2d it just uses zorder to draw back to front. In 3d there are some 3d layer settings that might help I suppose, like there is a setting to draw by zorder or by distance to screen. I could be remembering it wrong.

    The goal is to draw the 3d objects first, then draw the stuff with transparency far from the camera to close. That would work well if the billboard sprites face the camera, but when the quads are at many different angles there isn't any way to perfectly sort them in some cases with just changing draw order. Anyways just some ideas to fiddle with, or maybe what construct does automatically makes that less feasible. idk

  • Never played that game and probably never will. Guess its just a bunch of rooms connected by doors? And you don't see the new rooms till you enter the door?

    Easiest would be to just make all the rooms manually, and just reveal new rooms as you open doors.

    Tilemaps and sprites are just tools, I'd be more concerned at making something that works before making something that's super efficient.

    Random generation can get rather involved. One general idea with your rooms is to have each room fit within a grid with the doors on the edges. With the prefab rooms you should be able to hide that it is a grid. Then there's the matter of making all the rooms connect. One idea could be to utilize something like WFC (waveform function collapse) to let you generate the rooms on the fly. Basically start with a random room, then for each door place a room that has matching doors with the surrounding rooms, and if there are any sides with no rooms it can randomly have a door or not.

    Here's a test of the room linking idea where it generates more as it goes with a wfc like algo. I got bored before doing rooms over it.

    dropbox.com/scl/fi/z5uzt5vf20t0hiccp6keu/maze_expand.capx

    Another idea involves just defining each room, and saving it to some kind of text format to be able to load again on the fly. This literally just picks the next room at random at the doorway and removes the previous when leaving. Side effect is if you try backtracking the rooms will be different behind you, although I suppose this could be made persistent. Only supports a door per side of the room but with some tweaks you could support multiple doors per side.

    dropbox.com/scl/fi/6olz5ar4dk5ma7l2jtz81/crazyPathFromRooms.capx

    Anyways, all this is just to give ideas and was me trying some things out. You can probably find other similar examples. Maybe search for binding of issac examples. Those generate maps from room templates.

  • Do you mean something like this?

    1 2 3
    4 5 6
    7 8 9

    Say you remove the 2.

    1 0 3
    4 5 6
    7 8 9

    Then it shifts like this?

    1 3 4
    5 6 7
    8 9 0
R0J0hound's avatar

R0J0hound

Member since 15 Jun, 2009

Twitter
R0J0hound has 155 followers

Connect with R0J0hound