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

#1 2011-10-02 21:02:17

kodarr
New Scratcher
Registered: 2011-10-02
Posts: 18

Final Fight game sprite order question

First off the background is scrolling and doing this I'm using 10 different sprites that make up the background.  This works fine. 
My largest problem is the order of sprites.  So when two sprites are lined up on the x axis the one that has the lower y position should be the one on top instead of the other way around.

I tried using code i found online for this where in the stage you put
When (green flag pressed)
forever
    broadcast "all front" and wait
    set Sprite-Index to 0
    broadcast sortSprites and wait

Then on each sprite have
When i receive "all front"
go to front

When I receive "sortSprites"
wait until (sprite Index = my index)  //don't know what my index should be i put y position here b/c couldn't find a my index in the code.  didn't say how to set this if it is a variable.
go back (y position + 180) layers

This code makes the characters flash since the background sprites pop up in front even if I try sending them back 5000 layers.  It never seems to help.

How can I get this to work?  Anyone have any ideas or have an example I can look at.

Offline

 

#2 2011-10-03 02:37:06

Jonathanpb
Scratcher
Registered: 2008-07-25
Posts: 1000+

Re: Final Fight game sprite order question

The script seems to be continuously broadcasting "all front"; the sprites will constantly move to the front. So maybe moving them back 5000 layers won't help in the long run?  hmm


"Human beings... must have action; and they will make it if they cannot find it.
-Charlotte Brontë

Offline

 

#3 2011-10-03 12:52:52

kodarr
New Scratcher
Registered: 2011-10-02
Posts: 18

Re: Final Fight game sprite order question

yes but the backgrounds don't have the go to front on them.  so I'm trying to keep them behind the other sprites while getting the other sprites to show up in the right order according to the y direction.

I was thinking of maybe just checking is touching sprite for this but I think that would be to slow to check for every sprite that could be possible rather than just getting the layers changed when someone changes on the y. 

this would be easier if there were some way to set to layer x rather than bring to front and then send back x layers.

Has anyone gotten anything like this to work?  Or is there no way of doing this that will not slow down scratch?

Offline

 

#4 2011-10-03 20:13:38

Locomule
Scratcher
Registered: 2009-08-24
Posts: 500+

Re: Final Fight game sprite order question

go back -1 = go forward 1 layer

and there are always exactly as many layers as you have sprites

for specific help, upload your project and then post a link to it here


aka Pain from DragonSpires, Delrith Online, BotBattle, Urban Dead etc etc lol

Offline

 

#5 2011-10-03 21:37:33

kodarr
New Scratcher
Registered: 2011-10-02
Posts: 18

Re: Final Fight game sprite order question

Here is the game as it stands.  http://scratch.mit.edu/projects/kodarr/2062825
there are going to be many zombies on the screen at once right now I have just one other zombie but I'd like to have around 20 different zombies at a time on the screen.  This would be easier if I could just set the layer.  I know I can move to front then back x amount. but this makes everything blink on the screen when the two sprites overlap.

You'll see a few different disconnected codes I have been trying.  I'd be thankful if anyone can figure out how to fix this.

Offline

 

#6 2011-10-05 15:46:41

kodarr
New Scratcher
Registered: 2011-10-02
Posts: 18

Re: Final Fight game sprite order question

can anyone tell what is wrong in the code yet?  Bumping this back to front page since I haven't heard a response since I posted.

Offline

 

#7 2011-10-06 23:38:42

kodarr
New Scratcher
Registered: 2011-10-02
Posts: 18

Re: Final Fight game sprite order question

bumping this off page 2 back to page 1.

Has no one ever made a final fight style game or a game similar to streets of rage, golden axe, TMNT the arcade game, splatter house, river city ransom, or any of those side scrolling beat em up games. 

I would love to see how people handle making a character that is closer to the bottom of the screen show up in front of the other characters so that you don't see anyone walking through the chest or head of the other characters.

I've been searching for game examples but finding games with specific mechanics is very hard with the limited search they have for projects.

Offline

 

#8 2011-10-07 23:24:49

GameCentral
Scratcher
Registered: 2011-10-05
Posts: 100+

Re: Final Fight game sprite order question

i got some info from combining all posts then picking out the best parts for my new game to be posted


http://i1237.photobucket.com/albums/ff468/sciteccf/gamecentral.gif
http://i.imgur.com/2RYxb.png

Offline

 

#9 2011-10-08 16:25:13

kodarr
New Scratcher
Registered: 2011-10-02
Posts: 18

Re: Final Fight game sprite order question

Do you have a link of your game that uses the layers to find out who is in front of who so there is no walking through faces of other people.

Or any info where I can find this since I been searching the forums and the projects for this with no luck.  If you found something I would be ever so thankful.  At this point I'm almost thinking scratch can't do this since you can't set layers only move up or down by x layers.  And when you send to front only to move back there is blinking of sprites and the game slows down to almost unplayable proportions.

Offline

 

#10 2011-10-11 18:16:53

kodarr
New Scratcher
Registered: 2011-10-02
Posts: 18

Re: Final Fight game sprite order question

Bumping back to page 1.  If anyone has done this please point me towards a project that uses it so I can see how to do this.
Thanks.

Offline

 

#11 2011-10-15 16:35:20

kodarr
New Scratcher
Registered: 2011-10-02
Posts: 18

Re: Final Fight game sprite order question

bumping back to page one.  Still can't get this working if anyone can even give me some hints on how to do this I'd be greatly appreciated.  This would be so much easier if you could just say set layer x.  but with the go to front then moving back the sprites blink constantly.

Offline

 

Board footer