R0J0hound's Forum Posts

  • You can do it without behaviors. Just give the object an x and y velocity and do the bouncing by checking if walls are going to be hit horizontally or vertically. If they are, then reverse the velocity.

    Globals:
    G=100
    
    Instance variables:
    Vx=0
    Vy=0
    
    Every tick
    — sprite: add g*dt to vy
    
    Sprite: overlaps wall at offset (self.vx*dt, 0)
    — sprite: set vx to -self.vx
    
    Sprite: overlaps wall at offset (0, self.vy*dt)
    — sprite: set vy to -self.vy
    
    Every tick
    — sprite: set x to self.x+self.vx*dt
    — sprite: set y to self.y+self.vy*dt
    

    Just set vx and vy when the player throws it. You can adjust g to taste.

    Should be pretty close. At the very least you’ll get the perfect bounces. There are improvements that could be had. Here are a few of them that may be of interest:

    Possible improvements:

    The sprite needs to be outside of walls when it starts and throughout the motion. If it’s in a tight area, or it’s started inside a wall, then you need to move it out of the wall first.

    Usually not an issue if created inside the players collision area, and it’s given enough room to move around.

    There can be energy loss with vertical bouncing at times. The sprite will bounce lower after a few bounces.

    One reason for this is variable dt. You can help correct this by replacing self.vy*dt in all expressions with self.vy*dt+0.5*g*dt*dt.

    Bouncing is done by checking where the ball will be a frame later. You can get more precise bounces by calculating when the wall is hit exactly before bouncing then moving again with the remaining time. Not really necessary but has advantages for very fast sprites.

    A final idea is to only use integers for position and speed, and always use a fixed dt. This complicates it a bit but it removes energy loss from rounding caused by floating point numbers.

  • There isn’t any debugging feature for that, at least not in construct. The browser’s debugger can let you look at the JavaScript where it’s looping, but that is very abstracted away from events so it probably isn’t very useful. I mean if we wanted to deal with JavaScript and debugging it we’d be using something other than construct.

    Anyways,

    You don’t have to check every loop you have though.

    If you use “while”, then I’d pay attention to that. It’s the only way to create an infinite loop other than with function recursion.

    Just make sure it can exit the loop. If not then as a band aid you could replace the while with a repeat. That way it will just stop instead of looping indefinitely.

    The second thing to look out for isn’t an Infinite loop, but a loop that takes long enough that the browser asks to stop it. It happens with infinite loops too, but I digress.

    Are you looping over big arrays that are increasing in size?

    Do you have a loop that changes the number if iterations based on an expression that sometimes gives a very big number?

    Anyways that’s where I’d look.

    Ideas to mitigate that is to not loop over an entire giant array in one tick but do it in smaller chunks. Like half one frame and the other half the next. Big is the key word here.

  • There’s a system condition that checks if a xy position is overlapping a object. That should do it.

  • Just temporarily change them. So change them to allow the boost, then after a little time change it back.

  • The speed is limited by the max speed and the deceleration brings it to a halt fairly quick.

  • Wikipedia is your friend for the various methods and how they are done.

    Apart from utilizing JavaScript you can do something by looping over the characters and changing them to something else.

    The simplist would be something like replace

    0 with v

    1 with 7

    2 with ;

    ...

    And so on.

    Decoding would be the reverse.

    It’s as tedius as it sounds. Athough there are shortcuts.

    Anyways I’m going to have to defer to someone else to finish answering this one.

  • So the issue being that wait works with the timescale so when the timescale is 0 wait never stops?

    Wallclocktime is a timer that keeps going regaurdless of the timescale. Maybe that’s what you’d want to utilize.

    Global number stoptime=0
    
    On some trigger
    — set timescale to 0
    — set stoptime to wallclocktime+5
    
    Stoptime<=wallclocktime
    Trigger once
    — set timescale to 1
  • You’d do it as the last step. Like you’d get the json, then encrypt it. Then when you load you’d decrypt it first before loading the json.

  • A few ideas come to mind: encryption, compression, or even adding a checksum to the end to make sure it wasn’t modified.

    There may be plugins for all of them. I haven’t checked. I don’t use many plugins.

    There are probably other ways.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Probably need to use “add key” instead of “set key”. There are things that will silently fail so it’s best to test things as you go.

  • Sure you can. Rename a sprite to player, and add an instance variable to it called health.

  • What are you saving/loading exactly? If it's just variables then you could just use a dictionary object and set a value for each variable and get the json with the .asJSON expression. Loading would be done by using the "load from json" action and setting the variables from each of the values in the dictionary.

    on function "save"
    --- dictionary: set key "health" to player.health
    --- dictionary: set key "x" to player.x
    --- dictionary: set key "y" to player.y
    --- function: set return value to dictionary.asjson
    
    on function "load"
    --- dictionary: load from json function.parameter(0)
    --- player: set health to dictionary.at("health")
    --- player: set x to dictionary.at("x")
    --- player: set y to dictionary.at("y")
    
    start of layout
    --- Editbox: set text to function.call("save")
    --- function: call "load" (Editbox.text)
    

    It's basically the same for any data object. You could even just do your own save format, it's not hard.

  • Use an array instead of variables. Then you can do your check with one event

    start of layout

    array: for each x

    array.currentValue = "alert"

    --- aquire_tile: set animation frame to array.curX

  • Decimal numbers are seldom perfectly precise on computers. For example 0.2 can’t be precisely represented in floating point numbers so it will be a bit off which adds up with calculations. It’s not really that far off actually if you look at it.

    Anyways this is seldom an issue unless you’re displaying the numbers, because by default too many decimal places are displayed.

    A solution is to round the number before displaying it.

    Set var to round(var*10)/10

    Or maybe after every time you do a calculation, or before you want to compare a number to be an exact decimal number.

  • Clamp limits the range of a number.

    It’s clamp(number, low, high)

    So if the number is lower than low, it will use low.

    And if the number is higher than high, it will use high.

    Otherwise the number will be used as is.