R0J0hound's Forum Posts

  • You can just do it with the keyboard object.

    global text key=""
    
    on any key pressed
    -- set key to Keyboard.StringFromKeyCode(Keyboard.LastKeyCode)
    -- compare: key = "backspace"
    -- -- text: set text to left(text.text, len(text.text)-1)
    -- compare: len(key) == 1
    -- -- text: set text to text.text & key
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Here's what your events could look like to have basic functionality. You click buttons to setup the list of commands and clicking run will make the cat move.

    global number running=0
    global number step=0
    global text cmdList = ""
    global text cmd = ""
    
    clicked on LeftButton
    ---- add "left," to cmdList
    
    clicked on RightButton
    ---- add "right," to cmdList
    
    clicked on forwardButton
    ---- add "forward," to cmdList
    
    clicked on clearButton
    ---- set cmdList to ""
    
    clicked on runButton
    ---- set running to 1
    ---- set step to 0
    
    compare: running = 1
    every 0.5 second
    ---- set cmd to tokenat(cmdList, step, ",")
    ---- add 1 to step
    ---- compare: cmd = "forward"
    ---- ---- cat: move forward 32 pixels
    ---- compare: cmd = "left"
    ---- ---- cat: rotate 90 degrees clockwise
    ---- compare: cmd = "right"
    ---- ---- cat: rotate 90 degrees counter-clockwise
    ---- compare: cmd = ""
    ---- ---- set running to 0

    From there the rest is just visual stuff.

  • You can also take it a bit further and make the groups in the layout editor itself.

    dropbox.com/s/3xzkx3og9ay7gz7/objectGroupTemplates.capx

    You can extend it beyond just positions by just storing more in the arrays.

  • Decibels are actually on a logarithmic scale, so it would be:

    decibels = 20*log10(percent/100)

    0% -> -infinity db

    50% -> -6.02 db

    100% -> 0 db

  • Here's some examples:

    c2:

    dropbox.com/s/rpi4nzhd763b4l6/pointInPoly.capx

    dropbox.com/s/65neg3btcb6mdzr/pointInPoly2.capx

    c3:

    dropbox.com/s/ga41909z93g71nq/pointInPoly2.c3p

    I ended up converting the text point list to an array, but otherwise the math is the same.

  • For the math method you can do it by looking at a line from the point going down. If it crosses an odd amount of lines it’s inside the polygon, otherwise it’s inside.

    Here is what the events would look like if you just had sprites making up the points. You could use an array or text list but I’ll leave that as something that would need to be adapted.

    Global number x=100

    Global number y=100

    Global number inside=0

    Global number i=0

    Global number j=0

    Repeat p.count times

    — set i to loopindex

    — set j to (i+1)%p.count

    — value (x-p(i).x)/(p(j).x-p(i).x) is between 0 and 1

    — y > (p(j).y-p(i).y)/(p(j).x-p(i).x)*(x-p(i).x)+p(i).y

    — — set inside to 1-inside

  • The expressions

    Sprite.bboxLeft

    Sprite.bboxRight

    Sprite.bboxtop

    Sprite.bboxbottom

  • Guess it would be tricky converting everything over. Usually I just round as a last step and keep the unrounded variable and apply all changes to that.

    Anyways, here’s another idea to convert it. I’m assuming on your machine it runs at 60fps, so if you put all your events as sub-events to this it may work. It just only runs when the time passed is a 1/60th of a second. Just an idea at least. Triggers and new object picking may throw it off.

    Variable prevtime=0

    Compare: prevtime+1/60 <= time

    — add 1/60 to prevtime

    — put all events here

  • Well it should be as simple as:

    Every tick

    — sprite: rotate 100*dt degrees towards (320,240)

    Where 100*dt means 100 degrees per second.

  • Just replace the random() stuff to whatever you like. Random can be defined as random(min, max) of that helps. All a box is a low and high value vertically and horizontally.

  • You do not have permission to view this post

  • There’s a “rotate toward position” action that lets you smoothly rotate to face a location.

  • For something simple like variable that only increases or decreases you can utilize the trigger once condition.

    Variable timer = 10

    Every tick

    — subtract 123*dt from timer

    Timer <= 7.5

    Trigger once

    — set text to “three quarters left”

    Timer <= 1/3

    Trigger once

    — set text to “a third left”

    Timer <= 0

    Trigger once

    — set text to “done”

    Something that counts up would be >= instead.

    Another option could be to still change the variable by whole numbers but use a dt multiplied one to control it.

    Variable timer =0

    Variable countdown = 10

    Every tick

    — add 100*dt to timer

    Repeat int(timer) times

    — subtract 1 from timer

    — subtract 1 from countdown

    — if countdown=5

    — — set text to “halfway”

    — if countdown = 2

    — — set text to “a fifth left”

    — if countdown = 0

    — — set text to “done”

    Anyways those are two ideas that come to mind.

  • One way is to just spawn the objects in random positions and if the object collides with the player move it to a random position.

    Here’s one possible example. Create it on the player, and repeatedly move it to a random position till it’s not touching the player.

    On function “add spear”

    — Create spear at (playerbox.x, playerbox.y)

    — while

    — spear: overlaps playerbox

    — — spear: set position to (random(windowWidth), random(windowheight))

  • One way to do it would be with a second array. So if A is the first one B could be the second. And you’d do this:

    On function “journal”

    — B: set size to (0,2,1)

    — A: for each xy

    — — B: push A.at(A.curX, A.curY, 1) to front

    — — B: set at (0,1) to A.at(A.curX, A.curY, 0)

    — B: sort

    Then B would have the sorted list in the 2nd column.