Problems w/ Enemy Movement [See latest post]

This forum is currently in read-only mode.
0 favourites
From the Asset Store
Be discreet and rescue your friends from behind enemy lines.
  • Here are some problems that have been frustrating me enormously- In fact, I probably would not have joined this place so soon if I had been able to figure them out.

    SECOND EDIT:

    THE PROBLEMS IN THIS POST HAVE BEEN SOLVED IN SUBSEQUENT POSTS. SEE MOST RECENT POSTS FOR UNSOLVED PROBLEMS

    EDIT: THIS PARTICULAR .CAP'S PROBLEMS HAVE BEEN SOLVED IN SUBSEQUENT POSTS. SEE LAST POST MADE BY ME FOR UPDATED PROBLEMS

    .CAP found here; the project, as you see, is in its skeletal stages. No bullet-behavior enemies, no death traps, no life HUD yet.

    While you all d'aw at my cute sprite character (go ahead ), here are some specifics:

    I am making a simple test of a platformer game to be an "inaugural" project of sorts- with this done I can start working on my other projects which have been left on the sidelines, rotting in unfinished .CAP files (sound familiar?). I realized only after many failures that ya gotta start small before you go big. With some fundamental problems out of the way, I think i can go and finish this (with the only major hurdles being bug testing and level design), and be all proud of myself and stuff.

    Anyhoo:

    1) This platformer centers around pushing boxes to get to new heights and jumping on switches to open doors. Right now, the major problem is the switches. Here is a snapshot of my group event sheet for when the player jumps on the switch:

    <img src="http://i417.photobucket.com/albums/pp257/Emperor_Phoenix/Construct%20Problems/Problem1.jpg">

    One condition is not shown at the bottom (window size), saying

    Switch: Animation "Closed" is playing

    Now, I am trying to set it up that when the player jumps on the switch, a timer goes off, and this timer, after 2 or 3 seconds or something, resets the switch back to the "Open" position. I have tried using the timer behavior (to no avail), and the millisecond timer thing does not seem to be working in the least. It's probably something really simple that I'm overlooking, but it's really bugging the hell out of me. When I do a debug of the game, I notice that the private variable "Openness" goes straight to 3 when I jump on the switch, and just stays there. Is there something that I am missing? Any help would definitely be appreciated.

    2) To spice things up, as switches keep on resetting into the Open position, I have it so that you can push a block onto a switch and that will keep it closed so long as it is on top of the switch. I am somewhat pleased that I was able to figure out how to do that much on my own:

    <img src="http://i417.photobucket.com/albums/pp257/Emperor_Phoenix/Construct%20Problems/Problem2.jpg">

    However, the problem comes from moving the box off the switch. I'd like it so that when you move the box off, the switch resets to the open position once more. This does not happen- the switch never goes back to the open position once pressed, either by the player or the box. I suspect that it has something to do with the intrinsic coding of the switch itself, but I have tried lots of things to get that damned button to pop back up, and I am out of ideas.

    Solving those two would be a great boon for me, and I would appreciate any help given.

    For "touch up" optional questions, to make sure things continue to run smoothly, I have these to ask, but don't feel compelled to answer : )

    1) I originally set it up so that there were spawn boxes that would spawn doors and switches at pre-determined points on the world map. However, I ditched that in favor of just having copies of the same sprites all over the place. Was this a wiser decision?

    2) I would like to have it so that one particular switch opens one particular door- for example, I have the private variable Door set at 1 for a switch, along with the pri. var. Door set at 1 for a corresponding door. Is there a feasible way to set it up so that a switch always unlocks its corresponding door, instead of a long tedious event list? Something like "If Switch var. Door = Door var. Door, then do X" or something like that? Using the "Pick closest" can only take you so far, and I envision problems in the future. i set up switches and doors in the same container. Is this a hindrance to this plan, or a boon?

    3) This is more aesthetics, but the way I have pushing set up is that every time the player uses the push control on the box, it moves at a steady 205 pixels per second. This makes for some awkward moments when you lightly tap the box and it still flies. Is there a way to make the speed gradual?

    Of those 3, number 2 is the most important, but those are not major concerns right at this moment.

    Thank you for any and all help you send my way- I will be very appreciative of any kindness thrown to my small corner of the internet!

  • For #1 use the function object, and a private variable to pick.

    Call function after delay.

    http://sourceforge.net/apps/mediawiki/construct/index.php?title=Function_Object

    The timer behavior is better suited, since it remembers picked, but its bugged.

  • http://dl.dropbox.com/u/1487524/Scirra/ToyLand.cap

    Ok, I set up the things you were after the way I do things, and Added a few comments to those sections for you.

    1)

    I use systems like this for fiddly things, or multiple objects that need to be at the same place. For doors and blocks you are probably best to just manually place them, turn the grid, snap to moving and snap to resizing on.

    2)

    Matching switches to doors with a variable is perfectly fine. I use variables like this as my trigger system also.

    3)

    Added to cap.

  • I tried both methods, and initially, calling a function worked (and was rather easy to understand), but when I would jump on the switch, it would sometimes not go to the MyFunction I had set for it (which had me jumping on the switch three or four times before the Function was called). Is that a bug of some sort? The event I had was

    If Switch greater than 0 > Call Switch Function with delay of 3000 milliseconds

    On Switch Function > set Switch(Openness) to 0

    set Switch animation to "Open"

    However, using the time-delta trick worked like a charm, and I report back 100% bug-free behavior using that.

    Unfortunately, I just have no clue what the hell you did to get that equation!

    all that stuff about "clamp (openness) timedelta 100 * 10000" stuff is awfully confusing. I'll have a look at the wiki page about it to see if I can grasp it a little better.

    All the same, thank you both for your help- I very much appreciate it. It's nice to actually make progress for a change.

  • I will break it down for you, and you will see it is not too complicated

    Clamp(switch.value('openness') - 100 * timedelta, 0, 10000)

    I am doing this from memory so hopefully it is close to what I did for you.

    Clamp(A,B,C) is a useful event. It takes what you put in as A, and has B as a lower limit and C as an upper limit.

    So A is "switch.value('openness') - 100 * timedelta"

    Here I am subtracting 100 per second, you can set this as any value at all, but I like to use 100. When you jump on the switch, openness is set to 400, 400-100 per second is going to last 4 seconds. 600 would take 6 seconds etc

    B is the lower limit, so the value of 'openness' will never go below 0, and it will stop exactly on 0.

    C is the upper limit, which is not a specific value at all, just bigger than 400.

  • It looks like I'll have to dust off my old mathematics books.

    But ah yes, that makes the operation much clearer! Thank you friend, because I have a feeling that that is going to be a particularly useful tool in game-making; I think using it to control the timers on the doors will make things much easier.

  • Alright, there is only one major problem left- the correlation between a switch being "closed" and the door consequently being "open"

    Here is the set of events as I have them now:

    <img src="http://i417.photobucket.com/albums/pp257/Emperor_Phoenix/Construct%20Problems/Problem3.jpg">

    They do not work. I suspect I have yet to find the right event that distinguishes which switch and which door I want to act.

    the .CAP is here:

    http://www.mediafire.com/?yf32dq3r3qphako

    I have a feeling that I am close to finding a solution, but my tweaks have been less than effective. Essentially, if the switch (with value "Number" being equal to a corresponding door's value "Number") is closed (and the value "Openness" is greater than 0) I want the door to have its value "Open" set to 1. And then, when the switch is open, set that same value "Open" to 0.

    No one has to tackle this right away, and I am patient, and if need be, I'll just throw every idea i have into the damn thing to see if I can get a working solution. Anyone who does help, though, I will be rather appreciative of your assistance. I hope ya'll reading this have a merry Christmas

  • You should take a look at containers.

    http://sourceforge.net/apps/mediawiki/construct/index.php?title=Containers

    All the conditions with pick by value are confusing, when all you have to do is set that instances private variable to a Boolean... off or on. Likewise its container can have its private variable changed since it was placed in the selected objects list by the condition.

    You can then compare that objects private variable, and any instance of that object that meets the conditions criteria will be picked... as well as its container.

    Basically:

    doll on collision with switch

    switch set pv to 1

    oor set pv to 1

    // This is with door as a container to switch//

    //door is automatically picked when switch is//

    then

    switch compare private variable = 1

    do stuff

    //That will pick any instance of the object switch, that has its variable set to 1//

  • Hey, it's the weirdest thing. I removed the Pick instances from that event sheet I posted, and now it works fine.

    I had known containers were powerful before attempting this game, but I didn't know they could make things run so smoothly. I hope that holds up for the rest of my project.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Sorry to bump, but I figure that this is a simple problem to begin with, so it shouldn't take too much of anyone's time.

    The .CAP has once again been updated, and things are starting to look better: Switches and doors work, and pretty soon I think I can actually start focusing on cosmetics, more or less.

    The new .CAP is here.

    Here is what I'm trying to do:

    I am trying to set it up so that when the player falls on collision with some spiky pencils, the player is destroyed, and the death animation plays.

    When the death animation is done, the graphic for the player respawns, plays a "coming back to life" animation, and then the player itself is respawned, and the game continues. It's hard to explain, but if you run the .CAP, you know what I mean (the events for it are specifically in the Include "Lives and Game Overs" or whatever I called it).

    <img src="http://i417.photobucket.com/albums/pp257/Emperor_Phoenix/Construct%20Problems/Problem4.jpg">

    There is one problem with this:

    1) the main one being that the "revived" animation does not in fact play when the animation "Dying" is finished. I'm not sure why this is, but I suspect it's something simple.

    It's probably something I fudged up with global variables, but I am unsure. Take a look if you think you know what's up.

    In the cap itself, I have two instances of the pencils object. One is a tiled background simply labeled "Pencils" while the other being a sprite labeled "Spiky Pencils".

    I had assumed that using tiled backgrounds for long-range stuff like spiked floors, ground, etc. were better than using objects, because the less objects you use, the less RAM your game takes up. However, in all of my event finagling, there was no way I could get

    A) the death events to work when colliding with the pencils

    and

    B) the block to recognize the pencils as a surface so it could stop falling.

    Changing the tiled background to a solid obviously did nothing.

    Now, if need be, I can merely keep them as objects, but if there is a way to make the player and other objects interact with tiled backgrounds, I'd like to know. However, I doubt my project will end up taking that much RAM to begin with, but hey.

    Thanks for any and all help, as always.

  • You have on animation revived finished as a sub event to death = to 1, but if death is equal to 1 then......

    You need a trigger once under the initial death= condition, with the global changed to 0 right after its created. Then on revived finished could be a separate event.

  • You have on animation revived finished as a sub event to death = to 1, but if death is equal to 1 then......

    You need a trigger once under the initial death= condition, with the global changed to 0 right after its created. Then on revived finished could be a separate event.

    Umm, I am not sure I followed your advice, but this is what I did:

    <img src="http://i417.photobucket.com/albums/pp257/Emperor_Phoenix/Construct%20Problems/Solution1.jpg">

    And everything now works fine (with the exception of me not being able to change which angle plays during the death animation- which turns into an awkward flip if the player is at 180-degrees, dies, and then instantly flips to 0-degrees for the death animation. I tried setting the animation, but that don't seem to work).

    EDIT: it seems that that was just the odd bug. Because now i run it and the angle is all fixed. Sometimes odd glitches like that crop up in my test-runs.

    It's kinda odd, but with the event sheet I posted on the last page (the wrong previous one), it would create, in the debug, over 90 instances of the main character sprite, and it would glitch up the animation and slow the game down significantly. I really don't know why it would do that, but I'm glad at the least I have a workable (for now? I hope!) solution.

    In a dev-bloggish fashion, my next tasks include:

    -HUD creation (easy)

    -considering whether or not to destroy progress on a level (eg block placement) every time a player dies. I'm weighing costs and benefits.

    -designing some enemy sprites, but more importantly, actual cosmetics (backgrounds, environment)

    -events corresponding to a Game Over scenario

    And I envision future unexpected problems with all of those things! Joy!

    But now i celebrate a small victory, ha. Thanks for the help.

  • In the previous event sheet you had it spawn(ing) player(s) when death = 1.

    Since death was equal to 1 till the end of the revive animation.

    Good thing she didn't ham it up ehh?

  • Yikes, no kiddin'.

  • Here is yet another conundrum I've got on my hands:

    When I had solved the last major problem (the death animation one), I thought I was on easy street. That is, until I noticed a major bug in my programming: if one block was against a wall (and thus, its momentum was set to zero), it would treat all blocks as if they were against the wall on that same side, and thus, it would be impossible to push anything anywhere.

    I had originally thought this might be due to the fact that I had used spawn boxes for the blocks as opposed to just having separate instances of the blocks. So I did just that: I got rid of the spawn boxes and the events surrounding them, and just filled the layout with individual boxes. However, it seemed that that solved nothing.

    I then realized that I had made a mistake in my original programming: if a block was against the wall, I'd set its speed to 0, when that was entirely unnecessary. I toggled off those outcomes, and things ran smoother.

    However, if a block is still against the wall, it still adversely affects all the other blocks on the layout.

    Here is the .CAP if anyone wants to take a look.

    Here are my events as I have them now:

    <img src="http://i417.photobucket.com/albums/pp257/Emperor_Phoenix/Construct%20Problems/BlockProblem1.jpg">

    <img src="http://i417.photobucket.com/albums/pp257/Emperor_Phoenix/Construct%20Problems/BlockProblem2.jpg">

    When one block is against the wall, all other blocks move jerky and oddly, and I am not sure what is causing it. Well, I should clarify: I have a feeling that I have over-specific conditions for the event of a block against the wall, and this is causing a general muck-up on the .CAP's part.

    When I run the debug, it shows about 8 or so more instances of block than what is actually there on the layout. Weird. I have a feeling this may have something to do with it as well.

    Thanks for any insight.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)