-
I was wondering if anyone here was interested in producing a platform engine which can be used by everyone here. I started on the idea. I was able to get the character to fall, land on platform, move right/left/jump; however, the program behaves unpredictable at the moment. I figure that for now it would have to be fairly simple. By the way, there does not be an easy way to "insert" new code between lines. Re-writing the code to make any new changes seems abit of an inconvenience.
Saint Cheez
-
Senior Member
Sure...
Hi StCheez,
Anything is worth a look at. Can you provide any further detail/information?
-
Heres the basic program
I am using just square blocks to move around screen which I drew in jpg format.
sqr1 = main character in property allows for velocity
I set the y velocity to 10 thus it will go down automatically
sqr2 = platform in property allows for horizontal tile.
right cursor property on-key-down x velocity = 10 and on-key-up x velocity = 0; otherwise, sqr1 continues moving right past the screen.
left cursor property on-key-down x velocity = -10 and on-key-up x velocity = 0.
shift-key property on-key-down y velocity = -10 and on-key-up y velocity = 0. However, I got "jump" to work once, and now it does not. Not sure what the problem is.
Now for the actions:
1. collision
sqr1 rebounding box
sqr2
detects a collision between sqr1 and sqr2
set property sqr1 y-velocity = 0
let standing = true
else
set property sqrl y-velocity = 10
let standing = false
end
2. Boundary
sqr1 Jump to other side
when it falls to the bottom of screen
3. Goto Frame
Scene 1
otherwise the program flow won't go back to collision detection, nor will the sqr1 fall. By the way, I noticed that when you use goto frame, sqr1 will land right on top of sqr2 rather stopping slightly behind and above it.
Thats it for now.
Here was my problem. My new code was set standing = true. Here is the logic.
If standing = true, then I can use the shift-key to "jump" off the platform. However, programming the properties of the keys seems to be separate from the programming of actions.
-
I was wrong. You can directly access "actions" from "element" properties.
For on-key-down
Pick add-an-action, then pick "if" condition
if Standing = true
Pick add-an-action, then pick "set properties"
sqr1 y-velocity = 10
Pick add-an-action, then pick "end"
Of course, when running the program, if you also press the cursor right key, sqr1 will jump right.
For on-key-up
Pick add-an-action, then pick "set properties"
sqr1 x-velocity = 10
Pick add-an-action, then pick "set properties"
sqr1 y-velocity = 10
Thus, after releasing the "shift" key, sqr1 will fall and to the right.
Whoops! I forgot that I do not want this to happen "all" the time, because sqr1 may be jumping to the left, which probably means that I have to test for jumping left or right conditions.
-
Senior Member
Can you upload the movie file somewhere, so that we might be able to play around with the coding? I understand what you're trying to do, but I think you may making it a little more diffucult than need be.........
-Jason
-
Guess I will upload the movie to my website. And, here it is:
http://www.stcheez.com/platform.html
Kind of weird. The "jump" will initially work, and later will not.
Anyway, I will post the page, when I upload the file. And, thanks for giving it a look.
[Edited by StCheez on 07-21-2002 at 07:10 PM]
-
Senior Member
Try this..........
http://members.aol.com/lucky13thday/platform.movie
I moved all of the code into a list of actions, took the loop off, and removed some unnecessary things going on. I also did a quick fix on the 'jump' using the spacebar(it's not perfect, but it works).
Feel free to ask about anything I've done here, and I'll try my best to explain it.
-Jason
-
Thanks, Zoranvedek!
I was not familiar with the List of Actions, but now I think I have a better understanding.
Never occured to me to get the y position which was nifty idea. Your code also help me to better understand the "get" action.
When I tried to get the character to jump, by pressing the space bar, I got this error:
'standing' is not a proptery of 'movie 5' ActionIf
Undefined variable 'standing' ActionIf
In fact, I have been having this same error when testing a condition before going into the "jump" action. I get the impression that I am suppose to define or initialize variables at the beginning of the program. However, there is no mention of this in the Help.
So, I took out this test condition, and the character jumped from the platform. It jumped up a short distance, then quickly fell down.
Thanks again for you nifty coding and help, Zoranvedek.
I am impressed
-
KoolMoves Moderator
Originally posted by StCheez
When I tried to get the character to jump, by pressing the space bar, I got this error:
'standing' is not a proptery of 'movie 5' ActionIf
Undefined variable 'standing' ActionIf
In fact, I have been having this same error when testing a condition before going into the "jump" action. I get the impression that I am suppose to define or initialize variables at the beginning of the program. However, there is no mention of this in the Help.
Thanks again for you nifty coding and help, Zoranvedek.
I am impressed
This can happen if you try to check a variable that hasn't been set yet. Just and an Action standing=false in the first scene of your movie. (or true if that's what is needed) and this should remove this error.
-
Hi Bret,
When you say "set", are you referring to "set proporties" for action or "let" variable = something?
I was not exactly sure how "set proporties" affected variable of velocity. To me, it looks like a counter both positive or negative directions. Setting velocity to zero seems to me like initializing variable, y velocity, to zero where the main character can not go either up or down, while its on the platform.
-
KoolMoves Moderator
LET
Originally posted by StCheez
Hi Bret,
When you say "set", are you referring to "set proporties" for action or "let" variable = something?
I was not exactly sure how "set proporties" affected variable of velocity. To me, it looks like a counter both positive or negative directions. Setting velocity to zero seems to me like initializing variable, y velocity, to zero where the main character can not go either up or down, while its on the platform.
Use Let for variables
Use Set for element properites.
-
how do i add
collision detection and a heath bar that work with a like a wall arould trees so you cant walk on them p.s. this is a rpg like zelda
-
KoolMoves Moderator
Re: how do i add
Originally posted by total_WAR2002
collision detection and a heath bar that work with a like a wall arould trees so you cant walk on them p.s. this is a rpg like zelda
Total there are two ways on is javascript the other in actions.
In Javascript:
From the 3dfa help file:
Collision detection
element1.collide (element2
This method returns true if the bounding rectangles of the two elements are intersecting.
Otherwise it returns false.
For Actions:
use the On Collision Action and pick the two objects.
Best bet would be to look at the insaneman movie. There is extensive collions detection method that would work well for what you want to do...(I thought I had told you about this)
-
Interestingly enough, the 1 box which I used as a tile showed as if 3 boxs, when the program is run. I drew a gif pic drawn in MS Paint. Not sure if that would make any difference in how the box was displayed.
Speaking of collision detection, I just learned that the collision detection only works for that 1 box.
If I specified 10 tiles of that 1 box both to right and left of the box, even though there is a long line across the window only that 1 box has collision detection. I am not sure what the purpose for this idea, unless maybe for drawing purpose. Or,
I can use different boxes to buildup my platforms, which is a slight inconvenience for me. Or,
I can use java script instead, which I may have to do. I would have to learn it though. I am not sure how reliable it is.
-
Senior Member
Originally posted by StCheez
Interestingly enough, the 1 box which I used as a tile showed as if 3 boxs, when the program is run. I drew a gif pic drawn in MS Paint. Not sure if that would make any difference in how the box was displayed.
Speaking of collision detection, I just learned that the collision detection only works for that 1 box.
If I specified 10 tiles of that 1 box both to right and left of the box, even though there is a long line across the window only that 1 box has collision detection. I am not sure what the purpose for this idea, unless maybe for drawing purpose. Or,
I can use different boxes to buildup my platforms, which is a slight inconvenience for me. Or,
I can use java script instead, which I may have to do. I would have to learn it though. I am not sure how reliable it is.
Put the box in a layer, give the layer properties/allow velocity and acceleration. Tile the box, and have the collision detection run for the layer and not the box.
-Jason
-
'standing' is not a proptery of 'movie 5' ActionIf
Undefined variable 'standing' ActionIf
This is the error which I got when I pressed on the spacebar to jump. As far as I can tell, the error happened because the variables were spelled differently:
Standing and
standing
Once this was corrected, the jump worked beautifully. Now the character can only jump when it lands on a platform.
-----------------------------------------
As for the weird display of the box Gif, I apparently defined it as a "tile" which for some reason distorts the appearance horizontally when displayed. It makes the box a tad bit longer.
So, I did not define it as a "tile", and it displayed normally. By the way, I realized that I could also stretch out the box to make it longer.
---------------------------------------
I was reading the "layer of elements" which is a rather handy tool.
---------------------------------------
Here is a new problem which I had noticed. I wrote out 2 collison detection routines for 2 different platforms. When I ran the program, it ran abit slow, and only the last of the two collision detections was recognized.
So, I am going to try something differently...
if collision or
if collision or
if collision
set properties
else
set properties
end
in order to test multiple conditions in one routine.
Thanks again for all your inputs.
-
I just put together a movie which uses JScript in order to detect collision with more than one tile. Here is the script:
Under the black called "platform"
if(Main_Char.collide(Yellow_Tile)||Main_Char.colli de(Green_Tile))
{
Main_Char.velocity.y = 0
Standing = true
}
else
{
Main_Char.velocity.y = 35
Standing = false
}
Interestingly enough, If I tested for collision in two separate tests for two different tiles, only the last test would be recognized. So, I used an "or" to test the two conditions which worked. Its kind of inconvenient, but it does work.
Under "Actions for Scenes"
Main_Char = element("skyjpg");
Yellow_Tile = element("yellowjpg");
Green_Tile = element("greenjpg");
The new movie can be downloaded from my previous post.
-
Thanks to Zoranvedek, I was able to come-up with a routine which causes an enemy to move back-and-forth on a platform. The new version of movie can be downloaded from my previous post. Heres the routine which was placed in the "Elements List of Actions" or something like that:
1. get set ax = x position of the redjpg or enemy.
2. test if x position is <= 78
3. if so, set proporties x volicity of enemy to 10
Here you might notice that the enemy moves every 10 pixels which would addup to 88, 98, 108,... Unless you read the right number exactly, the next test won't work...
4. elseif x position is >= 115
5. set proporties x volicity of enemy to -10
6. end
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|