R0J0hound's Forum Posts

  • do you want to shoot the bullet in the direction the camera is facing or do you want to shoot towards the enemy no matter what?

    For both first you need to add three instance variables to the bullet sprite for the velocity. I like to use vx,vy and vz.

    Then to make the sprite move you'd add an event like this:

    every tick
    -- sprite: set x to self.x+self.vx*dt 
    -- sprite: set y to self.y+self.vy*dt 
    -- sprite: set zelevation to self.zelevation+self.vz*dt 

    Now to shoot forward you'd set the velocities like this when you create the bullet:

    on click
    -- create sprite at (3dcamera.cameraX, 3dcamera.cameraY)
    -- sprite: set zelevation to 3dcamera.cameraZ
    -- sprite: set vx to 100*3dcamera.forwardX
    -- sprite: set vy to 100*3dcamera.forwardY
    -- sprite: set vz to 100*3dcamera.forwardZ 

    The 100 is the speed.

    To just shoot toward the enemy you'd do this:

    global number factor=0
    
    on click
    -- create sprite at (3dcamera.cameraX, 3dcamera.cameraY)
    -- sprite: set zelevation to 3dcamera.cameraZ
    -- sprite: set vx to enemy.x-3dcamera.cameraX
    -- sprite: set vy to enemy.y-3dcamera.cameraY
    -- sprite: set vz to enemy.zelevation-3dcamera.cameraZ
    -- set factor to 100/sqrt(sprite.vx^2+sprite.vy^2+sprite.vz^2)
    -- sprite: set vx to self.vx*factor
    -- sprite: set vy to self.vy*factor
    -- sprite: set vz to self.vz*factor
  • So you want to see if two object bounding boxes overlap?

    You can do that with two compares

    Compare: (sprite.bboxright>tilemap.bboxleft) & (sprite.bboxleft<tilemap.bboxright) =1

    Compare: (sprite.bboxbottom>tilemap.bboxtop) & (sprite.bboxtop<tilemap.bboxbottom) =1

  • I second the idea of putting the hex sprites in a family. You can call it “other” or something.

    Also the offset you’re using is off. It literally just needs an offset not a full position. Which would look like this:

    On tap hex
    Hex: active = 0
    — set color
    — set active to 1
    — — X hex overlaps other by offset (0, -384)
    — — — create hex at (hex.x+0, hex.y-384)
    ...

    As long as the hexagons have the collision polygon set up well and you’re creating them far enough apart from each other so the collision polygons aren’t touching you should be good.

    Another approach without families would be using the “pick overlapping point” condition.

    Global number createX=0
    Global number createY=0
    
    On tap hex
    Hex: active = 0
    — set color
    — set active to 1
    — set createX to hex.x
    — set createY to hex.y
    — — pick all hex
    — — X pick hex overlapping point(createX+0, createY-384)
    — — — create hex at (createX+0, createY-384)
    ...
  • Sorry, probably won’t be able to do anything with this for the foreseeable future.

  • Looks good to me. Good job.

    There will always be things that could be done better in any project. The important thing is you got it to work. The more projects you do the better you’ll be at it.

    Also I salute you for finishing it too. I tend to not to.

  • Since things are in a grid formation an array makes for a useful data structure to use. Mainly the ease of accessing things to look for matches. I say ease, because lookups are quick and are just one condition.

    That said, if you really don’t like the array object you don’t have to use it. You can access individual tiles with picking conditions. It may make some logic more complex though.

    Most tutorials and examples utilize arrays though. But if you get the gist of what they are doing down you should be able to come up with an alternative way of doing it.

  • You can make the trigger once with a variable and some events.

    Variable bool=false
    
    Condition
    — if Bool=False
    — — set bool to true
    — — do something
    Else
    — set bool to false

    But since you want to reset things you could utilize a dictionary or array which would make less variables all over

    Condition
    — if negated dictionary.hasKey("trigger1")
    — — dictionary: add key “trigger1” with value 0
    — — do stuff
    Else
    — dictionary: remove key “trigger1”

    You just have to have a unique key for each clump of events. And making it reset would be a matter of deleting that key.

    There may be a way to simplify that further. If the conditions can be just expressions then you could do one liners with a function.

    On function trigger
    - Param text key
    - Param number c
    — set return to 0
    — c <> 0
    — — negated dictionary haskey key
    — — — addkey key with value 0
    — — — set return to 1
    — else
    — — removeKey key
    
    
    Compare: function.trigger(“trigger1”, sprite.x>100) =1
    — do stuff
    
    Compare: function.trigger(“trigger2”, sprite.y<200) =1
    — do other stuff
    
    On any key pressed
    — deleteKey “trigger1”

    Anyways, just some contrived examples.

  • I’m unfamiliar with any games like that and tried to watch that tutorial but it’s pacing is pretty slow.

    How it’s done is literally like making any game. The only thing specific to that game style is you just make things visible or invisible to show motion.

    Key controls move the player.

    Any text would just be a spritefont, or a sprite per character, or if you are feeling more ambitious, a sprite per part.

    Then you have an update function that you call which with change what’s visible and check if conditions are met and whatnot.

    At its core you have a player that has a position and a list of objects. They all have a location, which is just one of the sprites that can be made visible.

    Every update you change the location and check if say the player has an object right above him.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can probably follow that tutorial to do it. Sure it looks different than doing it in construct but the variables and logic would be pretty much the same so it should be adaptable.

    All you're doing is changing the visibility of sprites. And there are probably many ways to do that utilizing picking arrays or whatnot.

    One way would be to take advantage of "pick nth instance" and the .iid expression.

    So just make your layout and lay down the sprites. probably a sprite type for the player and each column of falling objects. Then then use multiple instances of the player sprite for each horizontal position and instances for the vertical positions of the objects. The order you place the instances will matter.

    Anyways you could do the moving logic for the player movement like this.

    global number index=0
    
    every 1 seconds
    -- player is visible
    -- -- set index to player.iid
    -- -- player: set invisible
    -- key left is down
    -- if index>0
    -- -- subtract 1 from index
    -- key right is down
    -- if index < player.count-1
    -- -- add 1 to index
    -- pick index instance of player
    -- -- player: set visible

    falling objects could be done in a similar way.

    I mean the general logic could just be if certain objects are visible then do this or that. Even if you did it in the most verbose way possible it still would still be doable. I'd recommend just breaking it up into smaller problems and finding ways to solve those. Then find ways to combine stuff. It should be doable.

  • I may be overthinking it but when two objects overlap there isn't typically a single contact point but an overlapping area. If the collision shapes are convex there may even be multiple areas. A way to find those areas would be to take the collision polygons and applying some clipping algorithm to that, but that's not very trivial to do.

    As a second phase you could then find the midpoint of those areas to give you a single point.

    Alternately you could utilize an algorithm called the Separating Axis Theorem (SAT) to push the objects apart to just be touching and find that point. If the shapes are concave then it would be more complex to handle. This is also a bit involved to make.

    Another idea is to utilize something like a raycast. Check the points from the hilt to the tip of the blade to see if any collide. As soon as one does, stop checking more and use that point. You could use the condition "pick object overlapping point" to do the point collision checks, or you could use a small detector sprite that you place along the sword.

    Anyways here's the point example way to do it. The sword has it's origin at the hilt and an imagepoint at the tip.

    on sword collides with enemy
    repeat 10 times
    pick enemy overlapping point (lerp(sword.x, sword.imagepointX(1), loopindex/9), lerp(sword.y, sword.imagepointY(1), loopindex/9)
    --- stop loop
    --- create particles at (lerp(sword.x, sword.imagepointX(1), loopindex/9), lerp(sword.y, sword.imagepointY(1), loopindex/9)
  • One way you could do it is utilize log10() to find the number of digits of a number.

    Var number
    Var d
    Set d to int(log10(number)/3)
    Set text to int(number/10^(d*3)*100)/100 & mid(" kmbt", d, 1)

    So something like 123456789 would result in 123.45m. It works up to the trillions (t) but to handle higher numbers you’d have to add to the text in the mid expression.

  • I think there’s a third party plugin to get the date. You can find a list of plugins somewhere on the forum or I think you can find it on the add on exchange part of the website.

    Or you can use the browser object with a little bit of JavaScript to get the date with this expression:

    Browser.execJs("let d=new Date(); str(d.getMonth()+1)+'-'+str(d.getDate())")

    Which will give you 10-30 if it’s Halloween.

  • You can render to frames and import the frames as a 2d animation.

    There is also a third party plugin by mikal to load gltf files to display the 3D models with c3’s 3D. It also lets you play back animations in them.

    So if you can export gltf from maya that may be an option.

    Zbrush is the same deal. Just use a rendered image or export a gltf file to use with that plugin.

    So try out those options to see if what you want to do is doable in construct.

  • I don’t think they let you change the fov yet. You can switch between perspective and orthographic projection but that’s about it.

  • Here's one way to do it. You place sprites in order to make the path. Then as time passes they are made visible. An added nice feature is to draw lines between the points, as well as to a sprite moving along the path.

    dropbox.com/s/48gr76yk5flvasa/drawPath_overTime.capx

    This example only does one path. To do multiple paths the events would have to be tweaked.