brent_hamel's Forum Posts

  • So if its the specific math you need, then the way to calculate it is:

    Object1.yMin = -1800

    Object1.yRange = 2110 ( -1800 + 2110 = 310 )

    Object2.yMin = 410

    Object2.yRange = 840 ( 410 + 840 = 1250 )

    Object1.Y = -1272.5 ( this is where the player has placed Object1 )

    Object2.Y = ???

    // yOffset uses the values of yMin, Y, and yRange to end up with a value

    // between 0 and 1... this decimal is our percentage 0.25 = 25%, etc

    - Object1.yOffset = abs( abs( Object1.yMin - Object1.Y ) / Object1.yRange )

    // we can then use that percentage to easily place Object2, as it'll take the

    // yOffset percentage, and multiply it by object2.yRange, giving the same

    // percentage between Object2.yMin, and Object2.yRange

    - Object2.Y = Object2.yMin + ( Object2.yRange * Object1.yOffset )

    // By putting the actual values in:

    - Object2.Y = 410 + ( 840 * 0.25 ) // which equals...

    - Object2.Y = 410 + ( 210 ) // which equals...

    - Object2.Y = 620

    I'm sorry if this comes across as patronizing, its not meant to be, I'm just not sure at what level you're at with all this... does this help?

  • Are these moves supposed to happen smoothly over time? Or instantly, like once the player releases placement of object1, then object2 jumps to the appropriate place as a result?

    I ask about "over time" as you mentioned using lerp in your original post

    Either way, it leads me to think about these as percentages between their clamp values, determine the percentage that player one has selected, and then move object2 the same percentage between 1250 and 410

    If you're looking for the position change to move smoothly over time, then using lerp can help:

    lerp( a, b, x )

    lerp( starting value, target value, percentage of the distance to move each tick )

    so if you have:

    Set object2.Y to lerp( object2.Y, object1.yOffset, 1 )

    yOffset is the percentage between 310 and -1800 that the player has placed object1. object2.Y will then be set to the same percentage from 1250 to 410 immediately, as its travelled 100% of the way from where it is to where it should be this tick.

    If instead you have:

    Set object2.Y to lerp( object2.Y, object1.yOffset, 0.25 )

    Then object2 will only move 25% of the way there this tick, and now that its moved, the pixel distance between the two is shorter, so the next tick that 25% will be smaller. Lerp runs the risk of never reaching its destination and only moving smaller and smaller increments, so its good practice to check for a position that's really close to the target, and if its passed that position, set it to the target. Otherwise, it'll be lerping forever but essentially invisible to the eye.

    Is this close to what you're looking for?

  • If I understand correctly, you want the following to happen:

    object1.Y starts at 310 and then moves over time to -1800 (a difference of -2110 pixels)

    and at the same time:

    object2.Y starts at 1250 and then moves over time to 410 (a difference of -840 pixels)

    and you want object1 to trigger object2, and for both to reach their end positions at the same time?

  • Best performance so far appears to be using 256x240 single pixel TiledBackground objects, with the palette as the image, using X and Y offset to change the displayed pixel, however that's ~35 fps on my PC and ~45 on my phone when using remote preview... still not viable I'm afraid :(

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Oh, and I also tried the SetColor shader on the sprites (without changing their frames) and that was the slowest at about 10 fps (For some reason I thought the shader might be faster, but alas)

  • So here's the thing... I've recently been learning 6502 Assembly for NES programming, which then led me to learning about how emulators work, which has NOW led me to wondering if its possible to make a bare bones NES emulator using C3... I can load a rom just fine. I can parse it and disassemble it just fine. I can read and interpret the CHR data just fine. However... There doesn't seem to be any way I can emulate the creation of a frame of graphics, 60 times a second.

    I've tried the DrawingCanvas, but its too slow... I've tried 256x240 stationary single pixel sprites pre-loaded with the NES palettes colors as frames... also too slow... I've also tried using the TileMap plugin (which is comparable in performance to the sprites) and the best FPS I can manage is ~30 fps, which is 50% of what I need to have a playable emulator...

    Is this simply an impossible task for C3? I know emulators tend to be more resource hoggy than they'd seem given all the work they need to do, but if C3 can natively draw entire screen's worth of graphics at 60 fps, at a much higher screen res... then why can't I?

    Also... if I can't even do randomized noise at 60 fps, then there's no way I can evaluate the NES's 3 graphics layers to determine which pixel to show (or to show the BG color instead)

    Any input would be greatly appreciated

    Thanks

  • All points mentioned here are totally valid, however I have another to make...

    What C3 needs more than anything, is published games out in the wild.

    As someone that's used Construct since the Construct Classic days, I've routinely checked out other engines (as they all have shortcomings, and sometimes C3 hits me with a wall I can't work around), and the FIRST thing I ask myself when investigating any other engines is: what has been made with it?

    If I don't recognize the name of at least ONE game listed, generally I move on, not out of spite or anything, but out of a reaction of: it must not a capable tool, or no one else is using it either...

    Examples won't get anyone's attention, neither really will demos... only finished and sold games will, I'm afraid.

    While not aware of Scirra's financial situation, what would really help to ship games, would be to either offer or partner with a publishing service, especially if its capable of helping devs to completion, be it through direct tool support, project funding, distribution, etc...

    If there are few to no visible games in the wild, then the engine isn't visible either... and that sucks, because Construct 3 is awesome.

    Is the cost to entry high for young, new, solo devs? As someone in Canada, yes, I have to justify my monthly subscription to my wife every month, as C3 still has yet to bring in any revenue to our household to justify my continued use of it.

    Are there features that newcomers will be looking for that aren't in place yet? Of course there are. Whether or not those are in the pipeline or never intended is unknown, but they will be viewed as "currently missing".

    Does that mean the tool is no good? Absolutely not, C3 is fantastic. But no one knows about it when there are no tangible and visible projects made with it. MIGHTY GOOSE is probably the most well-known/obvious title that we can all point to, which is a great start, but there needs to be more.

    So my point is, whatever can facilitate more finished games of quality and polish, getting out the door, and making a little money, in app-stores, e-shops, Steam, Switch, PlayStation Store, Xbox, whatever, is what NEEDS to happen.

  • Playback I'm not concerned about, as I prefer to use my own samples for specific games, its purely the reading of midi device input that I'm curious about, so thank you for the link! Not being a JS programmer, and someone that only uses the Event System in C3, I may have my work cut out for me in terms of incorporating this, however its a start for sure!

    As for MIDI devices, I have a few kicking around ;) (My primary background is in digital audio lol)

  • https://www.midi.org/midi-articles/about-web-midi

    I've been poking around trying to find a way to allow users to use USB Midi controllers as a form of input, but to no avail... I did read that (quite a while ago now) there was a brief discussion about MIDI support in browsers, and whether or not it would ever make it to C3 if it came to fruition. According to the link I've shared, it seems it has (unless I've missed something) just wondering if there's something I'm missing in terms of interacting with WebMIDI currently, or if its just straight unsupported, and if so, when it might become supported... as midi is a FANTASTIC way to reduce load times for game music, its way more flexible in real-time during gameplay (riding Yoshi in SMW adding bongos to the current music is a classic example), and is something I'd LOVE to see available in C3... I'm not a JS programmer, but I do understand the MIDI Binary format, so while I can happily load a midi file as a project file, drop its contents into an array, and play it back using pitched samples... I'd really love to be able to allow user control with a USB MIDI input device as well... thoughts?

  • You can't just replace an image in a spritefont, because different languages have different number of letters in the alphabet, and will require different settings for character spacing.

    This is why I also wanted a "Set Character Set" action, as obviously you'd need to update that to match the newly imported spritefont image

    ...I guess I'll just have to focus on English alphabet and Katakana font variants for now... as its not just about representing those languages, but also having differently styled fonts for each...

    It just seems odd to me that these features are missing from an image based object... and if not a simple oversight, then is it a technical reason for their absence?

  • I know I've asked this previously, to no avail, but thought I'd ask again in case anyone else has run into the same problem...

    Is there any way to alter the Spritefont image and character set once the program is running... Not sure why these actions have been left out of this object, but given that I not only want to support multiple languages per font (these are styled fonts of my own creation), but also different styles of font in general (also of my own creation), not having these seemingly simple (given that they appear to exist on every other graphics based object...) actions seems a bit silly, unless there's some technical reason for their ommission...

    Traditional fonts are 100% out of the question as they all look garbage at the pixel resolution I'm targeting... a given character must fit within an 8x8 pixel tile, with an empty column on the right side, and empty row along the bottom, making the character actually 7x7 pixels...

    Thanks in advance, although in the past this usually ends up with the advice of "use normal fonts" or "have a crapload of spritefonts already set up for each language and variation within the layout"... neither of which are helpful options I'm afraid...

  • > Looks like you can't load a file as binary with the AJAX plugin, only text

    No, this is possible in C3. You request a file with AJAX and then set response binary to BinaryData object.

    AWESOME!!! This is EXACTLY what I needed!! Thank you!! I can now:

    - load a binary file

    - pass it into an array as uint8

    - convert the uint8 values into HEX/Binary as needed for editing

    - edit said values at whichever addresses I need to

    - store them back as uint8 into the array

    - save the array to a destination binary data object

    - export it out back into my file system for external use

    This is fantastic. Like... a game changer for me. Seriously, thank you SO much for replying!

  • Just a quick question, as I've failed to find much online to help point me in the right direction...

    My goal is to:

    - load a Binary Data object with specific values from an external binary file

    - see them displayed as HEX using a text object tp verify they're correct

    - write them to a new external binary file

    What is the best approach to accomplishing this? I've noticed that simply including the source bin as a project file, requesting it through AJAX, saving it to the Binary Data buffer (UTF-8 Text seems to be the only option?), loading it into a text object (I've made my own decimal to hex conversion function) appears to function as expected, however, when I then try to write the binary data to a new file externally using AJAX, my file nearly doubles in size...

    What am I missing here?

    Thanks in advance!

    (Ideally I'd like to be able to write the bytes directly into the Binary Data object using either %00000000 Binary or #FF Hex... I don't suppose this is coming down the pipe any time soon is it?)

    I agree with Ashley that its better to use the advanced features of the behaviour... My own personal solution is:

    If CanJump = true, then

    If "Jump" is pressed, then set Y vector to "-JumpStrength" (as mentioned

    this does not allow for JumpSustain as it currently works)

    If "Jump" is released & Y vector < 0, then set Y vector to "Y vector * 0.25"

    (this essentially kills the jump but still allows the movement arc to feel

    natural)

    For coyoteTime:

    If OnGround = true, then set "Coyote Timer" to 1 (or whatever duration you prefer)

    Else set "Coyote Timer" to "Coyote Timer - dt"

    If "Coyote Timer" > 0, then CanJump = true

    Else CanJump = false

    So basically I check the conditions for CanJump, ie: IsOnGround, JumpCounter is less than JumpMax, CoyoteTimer > 0, etc, and then execute my jump with Set Y Vector, and do my own Sustain method. Honestly, for my purposes it works flawlessly, and to be fair, Construct 3 is intended to be accessible for beginners to help them learn to become more advanced... I honestly think adding the DoubleJump to the platform behaviour was overkill, as it was also easily done in events...

    Btw, I only use events, I have 0 code writing ability beyond doing some simple equations inside of event value fields... so like testing basic conditions and doing basic math instead of entering hard values into a given field...

    Hope this might help, cheers!

  • Hey all,

    Just wondering if there's a way to set up an Enum. I've created an input handler that reads the input state of 16 different inputs ( replicating a gamepad without being tied to the Gamepad plugin ).

    This handler uses a string that stores all 16 states, separated by commas, so when I test an input, I just tokenAt() the index I want for the specific input I want to test. Is there any way to tie these index values to actual string names for readability and convenience?

    I'm sure I'll remember the index order of all my inputs eventually... but it'd sure be nice to just type the name of the input I want and have the appropriate value serve as the actual index to be read from.

    example:

    current = "int( tokenAt( obj_inputHandler.inputState, 0, ", " ) )

    desired = "int( tokenAt( obj_inputHandler.inputState, Up, ", " ) )

    Is this possible or will have to come up with a workaround?

    Thanks in advance,

    Brent