Zebbi's Recent Forum Activity

  • I have a score, and if the player receives a 3 or 4 score (from racing laps), they get a small trophy; 5 , 6 or 7, they get a medium trophy, 8 or 9, a big trophy and 10+ a big trophy. I'm testing if a LocalStorage value is smaller than a lap, and if the value written in LocalStorage is lower than the lap, the trophy is shown. This works well, since if the player is replaying a level and they receive a lower score, it still retrieves and shows their highest won trophy ever for the level. When the get a higher lap than is saved in LocalStorage, it writes the higher score to localstorage and shows the new, bigger trophy. I also have a failsafe wheby is the the LocalStorage key doesn't exist, it writes the current lap to it regardless.

    Now, the problem is, I can't think of how to play a "tadah" sound the FIRST time the player wins the trophy. It has a tendency whatever I write to play the "tadah" sound upon retrieving the score from LocalStorage and displaying the trophy that has been won in the past. Any clue what kind of LapCount/LocalStorageValue test I would have to perform to make sure the "tadah" sound only plays the first time the play wins the trophy?

  • Sure it's possible. The simple overview of a mod player is it takes the file and generates sound as it goes, a chunk at a time. Without webaudio it does this by creating a wav file that is then loaded and played. The issue is to make one chunk match the other precisely. Webaudio allows you to buffer sounds to be played seamlessly, as well as eliminating the the overhead of creating/loading the sound files by instead letting you write sound data directly. Of course the nitty gritty of it takes a lot more than that and some specific knowledge, not to mention a lot of time to make and optimize. Using an existing js library is dependent on if one can be found and devising a way to use from C2, which is a time consuming task in and of itself.

    Converting to ogg is the fastest solution and gives the best performance since sound doesn't need to be generated.

    Ah, so you can't process the mod in realtime without webaudio? The reason I ask is the purpose for using mods is to adjust the speed of playback dynamically throughout the game (and to minimise filesize, but that's irrelevant), are you saying without webaudio, the module would have to be processed offline by the javascript library and then played back as a wav? Or could it still playback the module whilst being able to adjust the playback speed of the module in realtime by just playing a raw audio output, all without webaudio?

  • I have a few "for each" loops, and I also have a condition to check whether or not a tween is still running. If the tween isn't running, would this improve performance, or does the game still have to check the "for each" loop? Is there a way of disabling loops when an instance of an object is no longer needed to be tested (in this case, I have for each loops to make play sound effects , but when the sprite isn't moving, it wont move any more, so the loop testing will no longer be necessary).

  • Probably using the collision polygon.

    Tried pinning 8 different detectors, but it ate resources on mobile, so I'll have to go with the basic option of creating a spark under the car and using my imagination

  • You have to have different sound files for each type of screech. Then measure the angle of turn (or maybe the rate of angular turning) and play the different sound files for each subset of action.

    Yeah, can the rate of the turn be measured, independently from the speed of the car?

  • Well if a javascript library that doesn't use webaudio can be found, then maybe that can be used. Or you could just convert your mod files to ogg files with some other software perhaps.

    I will have to for now (convert to ogg), unfortunately, I'd like to know if it's possible to process module files without webaudio? Since the only bit that's really important to the listener is the output, couldn't the rest of the work be done without webaudio?

  • Done, I created and pinned each detector sequentially in a big 16 piece event, pretty ugly but I'm not smart enough to do it with an efficient, dynamic loop :/

  • Zebbi

    The collision polygon isn't accessible from just events. That said, you can manually put the collision point locations in an array or something and just reference that instead. Or you can use a tiny sprite to find the collision shape by moving over an area and checking for collision.

    What would the most efficient way of doing this be really? Looping a bunch of points around the sprite?

  • This corner of the internet has a way:

    http://acko.net/blog/javascript-audio-s ... th-html-5/

    But that's just the basics.

    There also may be some older js mod players that don't use webaudio. Anyway I guess it's in the realm of possible, but unless someone makes it usable from C2 I guess this info isn't useful.

    Well, Gigatron is our module genius, but his implementations all use webaudio, like you say, it seems possible, R0J0hound but I'm totally (as you'd imagine) useless with proper code, so I haven't a clue how to implement such a thing. Maybe it would be possible to take Protracker https://www.scirra.com/forum/plugin-protracker_t129409?&start=40&hilit=MOD or something, and convert the webaudio parts to javascript and just send the output to html5 or something?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The idea isn't super difficult but i guess explaining it with text and implementing it is tricky.

    1. we first need to know if the player is colliding with a tilemap. This is dead simple with one event.

    2. we need to know what tiles the player is overlapping. This example here does that:

    viewtopic.php?f=147&t=123332&p=877612&hilit=overlapping+tiles#p877612

    3. So now we have a list of tiles overlapping the player. Here's a collection of ideas that search gives to get a rough collision point between two objects:

    how-do-i-get-coordinates-of-span-class-posthilit-collision-span_p983039?#p983039

    Guess one idea would be to get an average of all the tiles and use that.

    Here's an idea to take the example from two and only use the part of the tile that's overlapping:

    https://dl.dropboxusercontent.com/u/542 ... oint2.capx

    works well if the sprite is only slightly overlapping the tiles

    R0J0hound Can this example be modified to work with collision point data on tiles, rather than just the entire tile?

  • Yes. R0J0hound's examples had a TileMap mechanism.

    Trying this:https://www.scirra.com/forum/get-the-x-and-y-of-a-span-class-posthilit-collision-span-span-class_p1025697?#p1025697 adjusting the code to match my car, at the moment it's not resizing the masking box to the size of my car properly, and it's occurring on impact of the tile regardless of the tiles collision polygon, am I missing something?

  • granpa's code (almost) does it (brackets were in the wrong place):

    x=(square1.x+square2.x)/2

    y=(square1.y+square2.y)/2

    Hmm, this doesn't seem to create the sparks at all now, before they created by at the same position as the car, but now they don't seem to be there? I just realized, I'm using tilemaps, so will I need to calculate it for the tile the car collides with?

Zebbi's avatar

Zebbi

Member since 20 Jan, 2014

None one is following Zebbi yet!

Connect with Zebbi

Trophy Case

  • 10-Year Club
  • x3
    Coach One of your tutorials has over 1,000 readers
  • Email Verified

Progress

12/44
How to earn trophies