R0J0hound's Recent Forum Activity

  • Ah, I guess I should have clarified in the other topic. You probably need to look at some actual JavaScript regex documentation.

    This one covers the flags about 2/3 of the way down the page.

    developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions

  • You could utilize tokenat with a loop and “.” As the divider. Then just rebuild the text a token at a time adding the “.” In between. Except when loopindex=2, you can add a “!” Instead.

    Otherwise there may be some regex incantation, but you have to dig into the docs for that.

  • calminthenight thanks!

    mOOnpunk Hey that's pretty cool looking.

    After trying out a few ideas I think the first step would be to decide on what data format you will be using first. Whether Array, Dictionary, json or even some contrived text format you make a parser for.

    The next step would be to manually make passages with the data format you chose.

    Then you'd have something kind of game that uses the data.

    Anyways, I like custom text formats so I wrote a parser. I wanted to be able to put the text links anywhere inside the text so a parser was useful.

    Had to do manual word wrapping since I made it so you can put clickable text anywhere. Also had to use some js because the .textWidth expression is delayed a tick so it's basically worthless.

    uc12be91c135585d1e6881a8e95b.dl.dropboxusercontent.com/cd/0/get/Ch8Td0aKdzI81bWNByu5u2ciYYpiQpSS849fcSBn8NyRII7uPgWyCV5M9XpKLrCIegwwGw6-FQW-hiSWZGgDXNzs8ml-nsTpxliiYVz5KYdVav2zuRriIGNVSeIxnI2MQPi_ogbs_0DnmxKlRH6Ij626/file

    I probably got carried away with the parsing. There may be simpler ways, but a least by parsing it's possible to extend it to have some scripting more like twine.

    Anyways, I never got to the visual editor portion. Maybe i'll try that later.

  • I concur you could make your own editor with construct to write blocks of text and drag them around. You could then export it into any format you like.

    You could also make the editor in the game you're making and utilize local storage for fast iterating instead of having to export and import the file every time you make changes. You'd just need to export and import the file before exporting your game since local storage isn't carried over.

    Guess the basic structure of the data you'd need is: the name of the passage, the text of the passage, and a list of the branching options (text and passage to link to). Personally i'd do it all as plain text like this and parse it. But if you make your own editor you can visualize the links between passages, and check it to make sure all the linked passages actually exist and there were no typos.

    #start
    You decide to start to learn to make games, 
    so you open up this cool new software.
    {continue... |next}
    
    #next
    You plug away at learning the software for a few minutes, 
    but then discover it uses math!
    What do you do?
    {Yeet the pc out the window. |yeet}
    {scream!! |scream}
    {faint in despair. |faint}
    
    #yeet
    Losing no time you slam the window open, 
    and with fire in your eyes you yank that 
    mathematical devil device from your desk, 
    and toss it out the window with all your 
    might out into the abyss!!!
    {Peace at last...|end}
    
    #scream
    Noooooooooooooooooooooooooooooooooooooooooooooooooooooooo!!!!!!!!
    {...and you pass out. |faint}
    
    #faint
    You wake up on the floor, unaware of how much 
    time has passed. You also don't recall 
    what you were doing...
    {...continue|start}
    
    #end
    Thank you for playing.
    {care to try again? |start}

    Just typed like that or even written linearly in json or what have you probably can become unruly pretty quick, but then I'd want an editor to help with that.

    You could add some scripting to it by going the parsing route so it could be more lke twine with variables and conditions. It just depends on what you want for your game.

  • It was a specific shape. each action has an angle and distance to specify the lines that make up the shape. For example a triangle can be made up of three lines: red,blue and green.

    That said, it can be made generic but in c2 I can't access the collision polygon so I'd use imagepoints instead. As long as the points make up a convex shape and points are placed clockwise. Although the winding order can be worked around.

    edit:

    Here you go:

    uc6884ebb94a2a0f3a64446afdb7.dl.dropboxusercontent.com/cd/0/get/Ch7FVCNBzROWPtaePfgxo_4Pl4dPHyuug9-0BICllURxfS87wdezg5CKIx4xqgsbGQcKZ27KtA4Kpwb39ssLSjFjVAbv5LQQ0h0pNzGKLfKm05h1xAAfQVNsjvqhKwBpTMNcxAfjFHzjkMajMHVgdSYK/file

    Just as long as it's a convex shape and the origin is within that shape. CW or CCW doesn't matter.

  • Cool. Glad it was useful.

  • So if I'm looking at that right looks like you have the origin of the wave at the front so you're doing something like this?:

    on wave collides with ship
    -- create explosion at (wave.x, wave.y)
    -- destroy wave

    The main idea i have is you can clamp the explosion position to the shape of the ship. This is simpler when the shape is simple.

    Since the ship isn't rotating is you can clamp the position that you create the wave to the bounding box of the ship. Anyways that works well for unrotated box shapes, so the ship from the right could still have floating hits.

    on wave collides with ship
    -- create explosion at (clamp(wave.x,ship.bboxleft,ship.bboxright), clamp(wave.y, ship.bboxtop, ship.bboxbottom))
    -- destroy wave

    If you want to clamp to a rotated box it would be this as long as the ship's origin is centered.

    on wave collides with ship
    -- create explosion at (wave.x-ship.x, wave.y-ship.y)
    -- set explosion position to (self.x*cos(ship.angle)+self.y*sin(ship.angle), self.x*cos(ship.angle+90)+self.y*sin(ship.angle+90)
    -- set explosion position to (clamp(self.x, -ship.width/2, ship.width/2), clamp(self.y, -ship.height/2, ship.height/2))
    -- set explosion position to (self.x*cos(ship.angle)+self.y*cos(ship.angle+90)+ship.x, self.x*sin(ship.angle)+self.y*sin(ship.angle+90)+ship.y)
    -- destroy wave

    Similarly you can clamp to a circle shape. Here a circle with radius 100.

    on wave collides with ship
    -- create explosion at (angle(ship.x,ship.y,wave.x,wave.y), min(100, distance(ship.x,ship.y,wave.x,wave.y)))
    -- set explosion position to ( ship.x+self.y*cos(self.x), ship.y+self.y*sin(self.x))
    -- destroy wave

    Or even any convex shape. Although that can take more thought. Here is a triangle.

    on wave collides with ship
    -- create explosion at (wave.x, wave.y)
    -- explosion: move -max(0, (self.x-ship.x)*cos(180)+(self.y-ship.y)*sin(180)-50) pixels at angle: 180
    -- explosion: move -max(0, (self.x-ship.x)*cos(-60)+(self.y-ship.y)*sin(-60)-50) pixels at angle: -60
    -- explosion: move -max(0, (self.x-ship.x)*cos(60)+(self.y-ship.y)*sin(60)-50) pixels at angle: 60
    -- destroy wave

    And here's another way to do the rotated rectangle:

    on wave collides with ship
    -- create explosion at (wave.x, wave.y)
    -- explosion: move -max(0, (self.x-ship.x)*cos(ship.angle)+(self.y-ship.y)*sin(ship.angle)-ship.width/2) pixels at angle: ship.angle
    -- explosion: move -max(0, (self.x-ship.x)*cos(ship.angle+90)+(self.y-ship.y)*sin(ship.angle+90)-ship.height/2) pixels at angle: ship.angle+90
    -- explosion: move -max(0, (self.x-ship.x)*cos(ship.angle+180)+(self.y-ship.y)*sin(ship.angle+180)-ship.width/2) pixels at angle: ship.angle+180
    -- explosion: move -max(0, (self.x-ship.x)*cos(ship.angle-90)+(self.y-ship.y)*sin(ship.angle-90)-ship.height/2) pixels at angle: ship.angle-90
    -- destroy wave

    Sometimes you can have complex shapes be made up of multiple simpler ones. It just depends on what you're after.

    Anyways, just an idea.

    Edit:

    here's an example:

    uc7d5c10545a8acd02ed399fd7ca.dl.dropboxusercontent.com/cd/0/get/Ch7R5fLugEEBF_gExBmDIud7opjrSx5e5VIf8qmLyshohh4R4X_DwqBl1k1zgam_PgvBJpt4cYqej2rFCQG__8AVI0VwKaLDSg-k4dWam0iFzXhNGhZCCsukMU_ulqgf0ekUBMDIZY5gmWss543FevNY/file

  • I never use waits when I can.

    On function getXY
    While
    — set myX to int(random(300))
    — set myY to int(random(400))
    — array: at (myX,myY) =0
    — — stop loop

    The only issue is it will loop forever if there are no 0s in the array. It also could take a while if there only a few 0s. Depending on how robust you want it you could have it try random places first, then make a list of all the locations with zero and pick one at random, and lastly if there are no zeros you could set the variables to -1 or nan or something.

  • You can use cosp inside anglelerp:

    angleLerp(a0, a1, cosp(0,1,t))

  • Sounds good. Most tutorials and examples of gltf use webgl or OpenGL which is ideal for how the data is laid out.

    Gltf also only has lists of triangles but I think you could combine pairs of triangles that share an edge into quads when you first load things.

    I hadn’t planned on doing any more with this very soon. My free time and how I spend it changes a lot day to day. But I’ll likely reference it for later stuff.

  • So I had a more serious look at the gltf file format and partially made a loader for it.

    It requires gltf embedded files. My goal was to only get the transformed vertices from skinning and the scene graph, and play back animations. The meat of it is in js and isn't tied to webgl at all.

    I was originally visualizing it with sprites, but it was too slow so I made a setting to use c2's render directly to draw points.

    ucd84645539eb544f77cd0e2c5a6.dl.dropboxusercontent.com/cd/0/get/CiGCC9qorABRxP1Caqhm_yCvpyXETpMnorCAVv-9aLpF8uq53e6R8RcyYb2RdO6h2BE6_K5jbiw7WCzVPFw47DoOo0GvJqRWhMwBycAs5v2Cxjsfn-F2WqfAj_JGtzwrqTIhAydFW4VbA9-TwxudbKtK/file

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Construct seems to do funky sorting when objects have the same zelevation.

R0J0hound's avatar

R0J0hound

Member since 15 Jun, 2009

Twitter
R0J0hound has 156 followers

Connect with R0J0hound