This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-06-06 22:32:28

LEGOengineer261
Scratcher
Registered: 2011-11-16
Posts: 100+

Need help with platformer

Hey, I am working on a platformer that scrolls up, and I need some help. I made it, and its kinda glitchy and partway doesn't work, so I REALLY NEED either A GOOD PLATFORMER ENGINE to look at and compare, or INSTRUCTIONS ON HOW TO MAKE A GOOD ONE. I need one that is 100 percent working and not glitchy, and it has to work without color sensing , cause the platforms and character are all black.

I might give more info on the game, its just that I don't want people knowing about it like half a year before it comes out.. If you need to know to explain though, then I probable will.


http://i1156.photobucket.com/albums/p562/LEGOengineer261/IronmanSERIOUSBOSS.jpg

Offline

 

#2 2012-06-06 22:40:47

sonicfan12p
Scratcher
Registered: 2011-11-16
Posts: 1000+

Re: Need help with platformer

Well, if it helps, the Red Alert Collaboration project I've been working on has scroll x and scroll y, and a 15 by 11 screen map. All that terrain has is one script, and that's to keep it in place, that should help. Don't mess with the scripts while the project is running though, or it will be extremely slow.


Why are the secret organizations getting all the attention?  mad

Offline

 

#3 2012-06-06 23:21:48

LEGOengineer261
Scratcher
Registered: 2011-11-16
Posts: 100+

Re: Need help with platformer

sonicfan12p wrote:

Well, if it helps, the Red Alert Collaboration project I've been working on has scroll x and scroll y, and a 15 by 11 screen map. All that terrain has is one script, and that's to keep it in place, that should help. Don't mess with the scripts while the project is running though, or it will be extremely slow.

I'm sorry, you must not understand, my project is going to be a platformer only scrolling up and down (y). Thanks anyways though!  smile


http://i1156.photobucket.com/albums/p562/LEGOengineer261/IronmanSERIOUSBOSS.jpg

Offline

 

#4 2012-06-07 02:28:18

LEGOengineer261
Scratcher
Registered: 2011-11-16
Posts: 100+

Re: Need help with platformer

... Is anyone else going to reply? ...


http://i1156.photobucket.com/albums/p562/LEGOengineer261/IronmanSERIOUSBOSS.jpg

Offline

 

#5 2012-06-07 12:49:19

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: Need help with platformer

If you're up for a challenge (or you want to use a platformer base that's already made) you could check out array-based platforming.  Music Marathon (a collab between applejack, Hardmath123, and myself) doesn't actually use the "touching?" block at all.  Hopefully that'll help.  You can remix and change the sprites and levels if you want.

Offline

 

#6 2012-06-07 17:07:43

LEGOengineer261
Scratcher
Registered: 2011-11-16
Posts: 100+

Re: Need help with platformer

amcerbu wrote:

If you're up for a challenge (or you want to use a platformer base that's already made) you could check out array-based platforming.  Music Marathon (a collab between applejack, Hardmath123, and myself) doesn't actually use the "touching?" block at all.  Hopefully that'll help.  You can remix and change the sprites and levels if you want.

Wow, I was going to reply saying that I was up for any challenge, then I downloaded it and looked at your scripts. That is the most complex scripting I have ever seen on scratch, but boy does it work well!! You did an amazing job on that...
Anyways, I sadly can't use that because my platformer is going to be a different type. I REALLY appreciate it though! I'll just let it out and tell you that it will be a lot like doodle jump (and iphone/itouch/ipad game). But when I get a bit better at scripting and start incorperating hard math (not hardmath123, lol) into my games.

The problem is is that I am going to have tons of animations playing while the character is moving, and I can't use color sensing first cause it messes up in flash and cause its gonna be all black (besides the background).

I feel like I can trust you in just telling me ways of doing that, you don't need to find a project if you don't know of one like this. Again, I really appreciate you helping me.  smile


http://i1156.photobucket.com/albums/p562/LEGOengineer261/IronmanSERIOUSBOSS.jpg

Offline

 

#7 2012-06-07 19:14:26

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: Need help with platformer

Sure, I'd be glad to help!  The secret behind Music Marathon's platforming system is that the program knows the exact shape of every object on the field (rather than just storing an image of the terrain).  There are 6 types of tiles that each offer different player responses depending on where they are relative to the character. 

Now, if you want to make something like Doodle Jump, I think it wouldn't be hard to do so without color (or, in fact, sprite) sensing.  I've been experimenting with pen in Flash Turbo on my test account (ubrecma) and I think that you could do a Doodle-Jump-style game pretty well in the same way: with realtime penned (or stamped) platforms. 

[mega-post time]

Here's a brief overview of what the program should do:

For something like Doodle Jump, you want a set of platforms distributed randomly across the field (though constrained to not be too far apart).  Probably, you're thinking of y-scrolling, so the field should be bigger than the 480 * 360 Scratch display. 

You want the character to spring up with a given y-velocity whenever he falls down on a platform (not when he just touches it; it would be too easy otherwise).  In addition, he must completely clear the platform in order to jump.  In other words, a platform can't be jumped on until the player is at least a certain distance above it.  If this is true, he will jump if his y-velocity is negative (he is falling), his x-position is within the left and right bounds of the platform, and he is still above it by a certain amount (he hasn't missed the platform altogether). 

I think it would be entertaining if the game were infinite, and grew gradually more difficult.  If this were the case, you would need to dynamically add to the level, while also deleting platforms below the player by a certain amount (so that falling would reveal a chasm). 

Okay, let's talk about data types. 

We want to store a collection of platforms.  Presumably, they're all the same size, although we could add support for large and small, as well as springy, disappearing, fake, etc.  So, we set up a minimal data structure called a Parallel Array.  This allows us to store multiple pieces of data about each platform.  Each element of each list will represent one platform; we have one list for the platform's y-position, one for its x-position, one for whether the player can jump on it (as discussed above), one for its type, another for its size, etc.  You can have as many as you need (or just one, if all the platforms are the same type and the same size). 

We delete items at the beginning of the arrays when we want to get rid of old platforms, and we add items at the end of the arrays when we want to generate more.  We always add and remove items from all the arrays at once; this keeps our "table" of values level.  We know that there is a platform at ((item 4 of xPositions), (item 4 of yPositions)), and that that platform has a type of (item 4 of Types), and we know that the player either may or may not have cleared the platform based on (item 4 of CanJump?). 

When we add new platforms, we can set their y-positions to the y position of the last platform plus a random amount, up to a maximum.  As that maximum increases, the game becomes more difficult.  Here's an example in Scratchblocks.

set [MinY v] to (5) // Keep platforms at least 5 pixels above one another.
set [MaxY v] to (20) // Don't allow them to be too far apart.  

when I receive [NewPlatform v]
add ((item (last v) of [YPositions v]) + (pick random (MinY) to (MaxY))) to [YPositions v]
delete (1 v) of [YPositions v]
add (pick random (MinX) to (MaxX)) to [XPositions v]
delete (1 v) of [XPositions v]
So that's platform generation, sort of. 

Now, as for the physics, we'll say that the item in the list of x-positions represents the center of the platform, and that the item in the list of Sizes (or, if all platforms are the same, the Size variable) represents half the width.  Adding or subtracting the width to the x-coordinate will give the left or right bound of the platform.  The player is touching the platform if
<([abs v] of ((item (i) of [XPositions v]) - ([x position v] of [Player v]))) < ((item (i) of [Sizes v]) + ([Radius v] of [Player v]))>
Where Radius equals the radius of the bounding circle of the player.  The character doesn't have to be circular, but if we imagine he is, everything is easier. 

That's all for now, I'll get back later and finish this post up.

Last edited by amcerbu (2012-06-07 19:27:01)

Offline

 

#8 2012-06-07 20:05:09

LEGOengineer261
Scratcher
Registered: 2011-11-16
Posts: 100+

Re: Need help with platformer

amcerbu wrote:

[mega-post time]

Wow, it sure was!

amcerbu wrote:

I think it would be entertaining if the game were infinite, and grew gradually more difficult.  If this were the case, you would need to dynamically add to the level, while also deleting platforms below the player by a certain amount (so that falling would reveal a chasm).

Yah, I'm planning to do stuff like that, like increasing the chance of breaking/fake platforms, making the platforms smaller, etc.

amcerbu wrote:

We want to store a collection of platforms.  Presumably, they're all the same size, although we could add support for large and small, as well as springy, disappearing, fake, etc.  So, we set up a minimal data structure called a Parallel Array.  This allows us to store multiple pieces of data about each platform.  Each element of each list will represent one platform; we have one list for the platform's y-position, one for its x-position, one for whether the player can jump on it (as discussed above), one for its type, another for its size, etc.  You can have as many as you need (or just one, if all the platforms are the same type and the same size). 

We delete items at the beginning of the arrays when we want to get rid of old platforms, and we add items at the end of the arrays when we want to generate more.  We always add and remove items from all the arrays at once; this keeps our "table" of values level.  We know that there is a platform at ((item 4 of xPositions), (item 4 of yPositions)), and that that platform has a type of (item 4 of Types), and we know that the player either may or may not have cleared the platform based on (item 4 of CanJump?). 

When we add new platforms, we can set their y-positions to the y position of the last platform plus a random amount, up to a maximum.  As that maximum increases, the game becomes more difficult.  Here's an example in Scratchblocks.

set [MinY v] to (5) // Keep platforms at least 5 pixels above one another.
set [MaxY v] to (20) // Don't allow them to be too far apart.  

when I receive [NewPlatform v]
add ((item (last v) of [YPositions v]) + (pick random (MinY) to (MaxY))) to [YPositions v]
delete (1 v) of [YPositions v]
add (pick random (MinX) to (MaxX)) to [XPositions v]
delete (1 v) of [XPositions v]

OK... I think I understand what your saying about it... I could do it like this..

set [Platform1] to [45.120.80.3]
.. Then enterpret it as the first pair of numbers becore the dot as x, the next as y, and then size, etc.

amcerbu wrote:

So that's platform generation, sort of. 

Now, as for the physics, we'll say that the item in the list of x-positions represents the center of the platform, and that the item in the list of Sizes (or, if all platforms are the same, the Size variable) represents half the width.  Adding or subtracting the width to the x-coordinate will give the left or right bound of the platform.  The player is touching the platform if

<([abs v] of ((item (i) of [XPositions v]) - ([x position v] of [Player v]))) < ((item (i) of [Sizes v]) + ([Radius v] of [Player v]))>
Where Radius equals the radius of the bounding circle of the player.  The character doesn't have to be circular, but if we imagine he is, everything is easier. 

That's all for now, I'll get back later and finish this post up.

Okay. I get this part too.  smile

Thanks for the examples, a TON!!! Its been a big help in my game... I hope..  smile


http://i1156.photobucket.com/albums/p562/LEGOengineer261/IronmanSERIOUSBOSS.jpg

Offline

 

#9 2012-06-08 09:54:31

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: Need help with platformer

Is that enough information for now?  If you have questions about specifics, I'd be happy to help out with that as needed.  I'm also planning to make a very simple y-scrolling 1s1s Doodle-Jump-style game on my test account.  When I finish that, I'll post a link.

Offline

 

#10 2012-06-08 12:14:05

LEGOengineer261
Scratcher
Registered: 2011-11-16
Posts: 100+

Re: Need help with platformer

amcerbu wrote:

Is that enough information for now?  If you have questions about specifics, I'd be happy to help out with that as needed.  I'm also planning to make a very simple y-scrolling 1s1s Doodle-Jump-style game on my test account.  When I finish that, I'll post a link.

Yes, I think that's enough for now.  smile  Thanks! I'll check out your project when you post it!


http://i1156.photobucket.com/albums/p562/LEGOengineer261/IronmanSERIOUSBOSS.jpg

Offline

 

#11 2012-06-08 19:31:25

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: Need help with platformer

Okay, great.  I'll get started on that...

Offline

 

#12 2012-06-28 03:07:03

LEGOengineer261
Scratcher
Registered: 2011-11-16
Posts: 100+

Re: Need help with platformer

Okay, I made most of it but I'm stuck on one part that should be soo simple. I already ripped out all of my hair and thrown myself out of a window, and I'm about to release a swarm of nukes to blow up the world, so someone had better help before I do that.

I'll have a link up in a few minutes in my next post...


http://i1156.photobucket.com/albums/p562/LEGOengineer261/IronmanSERIOUSBOSS.jpg

Offline

 

#13 2012-06-28 10:56:02

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: Need help with platformer

Okay, I'll see if I can help you sort out the glitch.

Offline

 

#14 2012-06-28 13:31:36

LEGOengineer261
Scratcher
Registered: 2011-11-16
Posts: 100+

Re: Need help with platformer

Okay here it is, sorry I took forever to post, but I needed to go to bed cause it was past 1 in the morning.  tongue
Anyways, what I'm trying to do is make it so when the sensor sprite lands on any of the board sprites, it aligns exactly to it so he doesn't land weird. I obviously failed in it, cause every time I try doing that, he ends up going through the platform or some other crazy thing. Could you help me with that amcerbu? I know your an excellent programmer, so it shouldn't be too hard for you. I'll be sure to put you in the credits for special thanks to.  smile

Here's the project: http://scratch.mit.edu/projects/LEGOengineer261TEST/2641516


http://i1156.photobucket.com/albums/p562/LEGOengineer261/IronmanSERIOUSBOSS.jpg

Offline

 

#15 2012-07-01 22:30:03

LEGOengineer261
Scratcher
Registered: 2011-11-16
Posts: 100+

Re: Need help with platformer

OK, I figured it out now.  smile  I just messed up with some of the math, cause when I did it it was like some AM time.....


http://i1156.photobucket.com/albums/p562/LEGOengineer261/IronmanSERIOUSBOSS.jpg

Offline

 

#16 2012-07-01 22:45:06

fg123
Scratcher
Registered: 2008-11-13
Posts: 1000+

Re: Need help with platformer

You know that using color sensing won't mess up what ever color you want your sprite to be? It switches to the sensing sprite so fast that you don't see it change.


Hai.

Offline

 

#17 2012-07-03 13:42:26

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: Need help with platformer

Is it all working properly, then?

Offline

 

#18 2012-07-09 09:08:35

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: Need help with platformer

Did you manage to fix the bugs?

Offline

 

Board footer