Problems w/ Enemy Movement [See latest post]

For questions about using Classic.

Post » Mon Dec 20, 2010 7:28 am

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 :P ), 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:

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:


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!
Check out my VGM on my soundcloud page!
Video-Game Music: E.C.2151
B
7
S
2
G
2
Posts: 193
Reputation: 1,561

Post » Mon Dec 20, 2010 8:58 am

For #1 use the function object, and a private variable to pick.
Call function after delay.
[url:36t8g5yt]http://sourceforge.net/apps/mediawiki/construct/index.php?title=Function_Object[/url:36t8g5yt]

The timer behavior is better suited, since it remembers picked, but its bugged.
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Mon Dec 20, 2010 9:54 am

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.
B
9
S
2
G
4
Posts: 346
Reputation: 2,726

Post » Thu Dec 23, 2010 5:59 am

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.
Check out my VGM on my soundcloud page!
Video-Game Music: E.C.2151
B
7
S
2
G
2
Posts: 193
Reputation: 1,561

Post » Thu Dec 23, 2010 6:27 am

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.
B
9
S
2
G
4
Posts: 346
Reputation: 2,726

Post » Thu Dec 23, 2010 7:53 am

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.
Check out my VGM on my soundcloud page!
Video-Game Music: E.C.2151
B
7
S
2
G
2
Posts: 193
Reputation: 1,561

Post » Fri Dec 24, 2010 4:25 am

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:


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 :D
Check out my VGM on my soundcloud page!
Video-Game Music: E.C.2151
B
7
S
2
G
2
Posts: 193
Reputation: 1,561

Post » Fri Dec 24, 2010 6:28 am

You should take a look at containers.
[url:nzm7856g]http://sourceforge.net/apps/mediawiki/construct/index.php?title=Containers[/url:nzm7856g]

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
>door 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//
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Fri Dec 24, 2010 7:25 am

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.
Check out my VGM on my soundcloud page!
Video-Game Music: E.C.2151
B
7
S
2
G
2
Posts: 193
Reputation: 1,561

Post » Thu Dec 30, 2010 9:06 am

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).


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.
Check out my VGM on my soundcloud page!
Video-Game Music: E.C.2151
B
7
S
2
G
2
Posts: 193
Reputation: 1,561

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 6 guests