R0J0hound's Forum Posts

  • I mean, absolutex/y doesn’t take into account scaling or parallax at all. That’s why the position will differ from the actual mouse.

    Setting the sprite’s position to mouse.x/y will put it right at the mouse, but i don’t know what layer it uses by default. If you need the mouse position on a certain layer you can use mouse(layer).x/y.

    Or if you’re set on using absolutex/y you can adjust it to match with some trial and error:

    X = mouse.absolutex*scale+offset

    Just by eyeballing it it looks like you could start with a scale of 2 and an offset of 0. But any scale or resolution changes could through that off I’d imagine.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I never use parallax but not using it with a cursor would make sense.

  • I’m pretty sure that’s what he meant. But no worries. It’s early and I may be reading it wrong.

  • I don’t see how it’s a bad idea. Providing automatic focus on a new pop up window seems like what always should happen.

  • No that looks right. It would be going 1pixel/sec though. Instead of going forward and back by 1 you can move forward and back by the speed you want it to move.

    If that still doesn’t work then I’m misunderstanding something with how c3 does 3D.

  • Oh I see now.

    You could still use mouse.x instead.

    I mean mouse.x-scrollx which would be relative to the scroll position. Aka even if the screen scrolled that relative position wouldn’t change.

    So it should just be a matter of replacing mouse.absolutex and y

    With

    Mouse.x-scrollx and mouse.y-scrolly

  • Oh strange. I didn’t test it but that sounds like a bug then.

    Guess you could move the camera forward by one, save it’s position to variables. Then move back one and subtract the position from the same variables. That would give you a forward vector xyz.

  • Mouse.AbsoluteX gives the number of screen pixels from the left of the canvas.

    Mouse.X does more. It basically maps where the cursor is to the games coordinates.

    Probably something like

    Mouse.x = (mouse.absoluteX/windowWidth+0.5)*originalWindowWidth*scale+scrollx

    I guess I’m not seeing how absolutex is more useful. Guess I need to try that use case you mention.

  • 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.