mattb's Forum Posts

  • The pathfinding nodes get positioned to the nearest cell, so maybe what you could do is use your own movement system instead of pathfinding's in-built movement (eg. rexrainbow's MoveTo plugin), then have pathfinder create waypoints for each node. For the last waypoint, you'd ignore the final node & use mouse XY position (stored onButtonRelease when initially setting the path).

    There might be a way to do this with Pathfinding, but the only useful things I can see are the 'Is moving along path' condition & the 'CurrentNode' expression (NodeCount-1 would give you the final node), & no way of setting NodeX/Yat.

  • I'm trying to make a waypoint movement system where you double click to set the destination or append the current path. I found that the pathfinding behavior generates too many nodes for my purposes - I only want the bare minimum number of points but it sets extra ones around corners.

    So I fixed this with a hacky optimization where each waypoint has a line-of-sight behavior, & if it can see 2 nodes ahead then the following node is destroyed.

    This works & gives me a simplified set of waypoints. But, after 30-40 waypoints are made, there's some serious performance issues - cpu=100%, fps drops to around 40.

    I've attached a capx, maybe someone could take a look & see where I'm going wrong.

    Also if anyone has a better idea for generating a simplified set of waypoints then I'd love to know how.

    Thanks!

  • Forgot to include the capx...

  • I got the idea for this from someone in the irc chatroom (I forget who) & it's a fun control system that I thought a C2 beginner might find useful to examine, or better yet an experienced user might expand upon & share their results.

    It works by making the player a spinning disc, with left & right move keys setting the angular velocity. A ground detector sprite determines when you can jump, detecting overlaps with a family of 'solids' (ie. immovable physics sprites).

    High linear damping & some additional downward force is the key to making the player physics settle down faster & feel more like the platformer behaviour.

    There's a basic platformer sprite in the scene for comparison (arrow key control for that, & WASD for the physics one), & you'll see the weak point of the physics player is the air control which I could never get to feel right. Maybe someone could have a go at some better code for that.

  • I'm trying to do a swinging elastic rope for a platform game, on a sprite with either physics or platform behavior, & drawn simply as a straight line - no segmented physics joints.

    The swinging will be used to perform jumps etc, so momentum is important. I don't want a perfect circular pendulum motion.

    I'm new to programming & terrible at maths, so could use some ideas about where to start with this (although I suspect it should be with a highschool maths or physics textbook). I've attached one of my failed attempts below, which gives a rough idea of the motion i'm after...

  • I'm using the FileReader plugin for loading back into the array, so file extension doesn't matter. I did try saving it as a json too, & that has the same hit & miss wierdness.

  • I'm making a very basic level editor, & its save function works by creating a temporary tester sprite which scans over the playing grid, & an array is then filled with values from objects that overlap the tester.

    The problem I'm having is that when downloading the array as a text file, it doesn't always save properly. Sometimes it downloads what looks like a random string of chinese characters, other times it works.

    The problem can usually be fixed in the level editor by pressing its reset button (clearing the array & playing grid of objects), then laying out again & saving.

    Any idea what might be causing this hit & miss behaviour?

    fyi here's what the save events look like:

    <img src="https://dl.dropboxusercontent.com/u/52354372/save_array_problem.png" border="0" />

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'm making a very simple level editor for a tile based puzzle game which can save & load text files to & from an array. The same thing would work with the Dictionary object too.

    To save, I use this action on the array:

    Download as JSON data with filename TextBox.Text & ".txt"

    (TextBox is the object I use to type in the filename for saving)

    Loading uses the FileReader plugin, which might not be ideal for your program since it uses an uncustomizable web button & can't be called with actions - you have to click on the button then browse to your text file. This is fine for a scrappy level editor though.

    So, the loading process is:

    FileReader > on file loaded > Array > load from JSON string FileReader.fileContent

  • ADenton - I think your first step before working out any event logic should be to clearly define states & behaviours for your guard, & think through every possibile situation for him.

    I would have the states (stored in the guard as a combination of bools or a single text variable) for a guard in a shooter game something like this:

    Patrol - walks between waypoints, relaxed posture; initial behaviour

    Patrol alert - walks between waypoints, combat pose; this behaviour triggered after being previously alerted, & could return to the initial patrol after a time.

    Suspicious - hears noise & stops patrolling; walks towards point of last noise; waits there for several seconds; if nothing found, walks to closest waypoint & state changes to 'patrol alert'

    Attack - has player line-of-sight, or saw player within eg. the last 10secs; runs at player & shoots; if player shoots back then run to nearest cover

    Alisa - yes I'm using MoveTo at the moment for some elevators, very handy behaviour

  • i'm also a C2 (& programming) newbie so the deltatime might be redundant, but i'm pretty sure it's needed so that the sprite moves at 'speed' pixels per second instead of per frame.

  • hi alisa, here's a simple way of moving a sprite around with waypoints:

    https://dl.dropbox.com/u/52354372/waypoints.capx

    very basic, no acceleration or turning & the collisions are innacurate, but should be what you're after for simple background anims.

  • hi, here's how i've been doing my drag-drop with overlap checking:

    https://dl.dropbox.com/u/52354372/drag_drop_overlap_test.capx

    you could also do a simple check for the dragdrop behavior where you store the sprite's position on drag start, then on drop if it's overlapping another object you move back to that stored position.

    but i would go with a movement tester sprite like in the example - most games with drag-drop do something similar, & it just feels more intuitive having the preview of where you're moving.

    note - i've used a family in my example file for containing all blockable objects, so it might not open in the free version of C2.

  • This might be interesting reference for a class-based endless runner game: http://www.moddb.com/mods/the-great-class-dash

    As for how to start & organize your project, just play around with the platform behavior & the 'simulate control' action for your auto running at first. Do some experimenting & see what's fun.

    A non-C2 specific vid that might hold some useful design ideas: http://www.youtube.com/watch?feature=player_embedded&v=I05TDijQx-Q

    Nugget of wisdom from Yann that will help with generated scenery: http://www.scirra.com/forum/how-to-spawn-a-random-object-from-a-set_topic47744.html

    Also there's a helpful bunch in the chatroom - widget.mibbit.com

  • Yep it was a picking problem. Fixed it (learning a lot in the process) & thought i'd post the results so other Construct2 newcomers can have a look:

    dl.dropbox.com/u/52354372/rgb_beams_final_v2.capx

    <img src="http://i.imgur.com/mxVEQ.jpg" border="0" />

  • Thanks for the ideas, i'll check them out.

    So, another question about something that I've got half-working...

    <img src="http://i.imgur.com/5dlbA.jpg" border="0" />

    dl.dropbox.com/u/52354372/rgb_beams_test.capx

    Any idea where I'm going wrong?