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

#1 2012-06-01 23:49:39

Daqa
New Scratcher
Registered: 2012-05-31
Posts: 10

"3D" gravity?

Hi all scratchers!
     To make a short introduction, this is my third account in Scratch's site (due to forgotten passwords) and I'm a maybe "big" or "complex" project of creating game which involves jumping and some things more.
        OK, I'm not a native English-speaker. That means that if I explain t his stuff I need help with, you're very likely to get confused. I'll use a picture  as an explanation:


http://imageshack.us/photo/my-images/84/daqapreg.png/

(Please note that I'm not allowed to place images yet since I'm a recent member. So take the annoying task of pasting the link on a tab of your browser. Sorry  sad )

Offline

 

#2 2012-06-02 00:49:04

wasabi56
Scratcher
Registered: 2012-02-10
Posts: 500+

Re: "3D" gravity?

I don't exactly understand the diagram, but this may help... again, this is just to my understanding of the diagram...

<when[space v] key pressed>
Change y by (10)
set [place v] to (pick random(1) to(3))
this will only get you past the first little part, though...

Last edited by wasabi56 (2012-06-02 00:50:16)


http://i.picasion.com/pic58/c23d4d2fc75f459dcf3d9ebf3e8ba395.gif
http://www.weebly.com/uploads/1/0/1/4/10146167/2294523_orig.png

Offline

 

#3 2012-06-03 00:04:51

Daqa
New Scratcher
Registered: 2012-05-31
Posts: 10

Re: "3D" gravity?

Yeah, sounds interesting and gave me an idea.
   Thx.

  However, I'll try to explain in words:
You have 2 types of side-scrolling games. #1 Purely 2D (like Mario games) when you move forward or backwards and you can jump; and some other games (#2) allow you to move forward, backwards, up and down AND jump (that looks "like" 3D). In this second type, the game levels  something like lanes or similar and you move through them by moving up or down. If you are in a lower lane and jump, while you're in the air, it could look like you're in a higher on but then you land the jump, back to lane you jumped from.
     If you're in a high lane and jump, could look like you are in the scenario background, but you soon return  to the   high lane you were.
     Tryin to make it simpler:
     NOTE: since Scratch limits me to 480x360 res, I won't make more than 3 lanes in my game. Something like this:
               NORMAL (#1)
        1 <You're here> Jump  A <land here>  [1 ------> A]
                WITH "LANES" OR LAYERS (#2)
       1 <U may be here>  A    <U may land here>
       2 <U may be here>  B    <U may land here>
       3 <U may be here>  C    <U may land here>
         Possibilities:      1 ----JUMP-----> A (same lane) or B or C
                                2 ----JUMP-----> B (same lane) or A or C
                                3 ----JUMP-----> C (same lane) or A or C.

     Anyone got it?

Offline

 

#4 2012-06-03 00:17:20

AtomicBawm3
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: "3D" gravity?

Well as far as I can tell, all you really need is to have 3 variables involved: your x, your y, and your z.

X is your moving back and fourth.
Y is your jumping.
Z is your movement through the layers.

You want to make jumping completely independent of your lane movement it sounds like, so you could make controls like this:

Left arrow = x moves negative
Right arrow = x moves positive
Up arrow = z moves negative
Down arrow = z moves positive
space bar = jump

I don't know if this is what you want, but it sounds like it.


http://i50.tinypic.com/j0yw0p.jpg

Offline

 

#5 2012-06-03 00:40:12

Daqa
New Scratcher
Registered: 2012-05-31
Posts: 10

Re: "3D" gravity?

That's simply a GR8 idea, but if I'm not wrong it's not possible coz Scratch only manages x and y axis, and z axis should be something like y but with another name.... I don't know.

Offline

 

#6 2012-06-03 01:01:50

AtomicBawm3
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: "3D" gravity?

Daqa wrote:

That's simply a GR8 idea, but if I'm not wrong it's not possible coz Scratch only manages x and y axis, and z axis should be something like y but with another name.... I don't know.

You can determine a sprite's projected position on a 2D plane very simply by dividing by the z.  In your case, the closest lane to the bottom of the screen is z=1, then as you go up the screen, z=2, z=3

your x, y, and z are completely independent.  Your sprite's x position and y position are determined by x/z and y/z respectively.  If you want more help, I can point you to few projects that show this or simply make an example.


http://i50.tinypic.com/j0yw0p.jpg

Offline

 

#7 2012-06-03 01:05:50

wasabi56
Scratcher
Registered: 2012-02-10
Posts: 500+

Re: "3D" gravity?

Daqa wrote:

Yeah, sounds interesting and gave me an idea.
   Thx.

  However, I'll try to explain in words:
You have 2 types of side-scrolling games. #1 Purely 2D (like Mario games) when you move forward or backwards and you can jump; and some other games (#2) allow you to move forward, backwards, up and down AND jump (that looks "like" 3D). In this second type, the game levels  something like lanes or similar and you move through them by moving up or down. If you are in a lower lane and jump, while you're in the air, it could look like you're in a higher on but then you land the jump, back to lane you jumped from.
     If you're in a high lane and jump, could look like you are in the scenario background, but you soon return  to the   high lane you were.
     Tryin to make it simpler:
     NOTE: since Scratch limits me to 480x360 res, I won't make more than 3 lanes in my game. Something like this:
               NORMAL (#1)
        1 <You're here> Jump  A <land here>  [1 ------> A]
                WITH "LANES" OR LAYERS (#2)
       1 <U may be here>  A    <U may land here>
       2 <U may be here>  B    <U may land here>
       3 <U may be here>  C    <U may land here>
         Possibilities:      1 ----JUMP-----> A (same lane) or B or C
                                2 ----JUMP-----> B (same lane) or A or C
                                3 ----JUMP-----> C (same lane) or A or C.

     Anyone got it?

Okay, I get it now, you could have the 3 lanes be sprites and have:

<when [space v] key pressed>
perform jump you want

when gf clicked 
forever
if <touching [sprite 2 v]?>// lane #1
set [lane v] to(1)
end
if <touching [sprite 3 v]?>// lane #2
set [lane v] to(2)
end
if <touching [sprite 4 v]?>// lane #3
set [lane v] to(3)
end
If you need help with the actual gravity after this, just ask  smile

Last edited by wasabi56 (2012-06-03 01:07:37)


http://i.picasion.com/pic58/c23d4d2fc75f459dcf3d9ebf3e8ba395.gif
http://www.weebly.com/uploads/1/0/1/4/10146167/2294523_orig.png

Offline

 

#8 2012-06-03 01:17:20

Daqa
New Scratcher
Registered: 2012-05-31
Posts: 10

Re: "3D" gravity?

wasabi56 wrote:

Okay, I get it now, you could have the 3 lanes be sprites and have:

<when [space v] key pressed>
perform jump you want

when gf clicked 
forever
if <touching [sprite 2 v]?>// lane #1
set [lane v] to(1)
end
if <touching [sprite 3 v]?>// lane #2
set [lane v] to(2)
end
if <touching [sprite 4 v]?>// lane #3
set [lane v] to(3)
end
If you need help with the actual gravity after this, just ask  smile

Alright, thank you. But how will Scratch understand "lane=1" means "jump from lane 1 and come back there"?

Offline

 

#9 2012-06-03 01:21:55

Daqa
New Scratcher
Registered: 2012-05-31
Posts: 10

Re: "3D" gravity?

AtomicBawm3 wrote:

You can determine a sprite's projected position on a 2D plane very simply by dividing by the z.  In your case, the closest lane to the bottom of the screen is z=1, then as you go up the screen, z=2, z=3

your x, y, and z are completely independent.  Your sprite's x position and y position are determined by x/z and y/z respectively.  If you want more help, I can point you to few projects that show this or simply make an example.

Please point them. (I love reverse engineering)

Offline

 

#10 2012-06-03 18:26:03

wasabi56
Scratcher
Registered: 2012-02-10
Posts: 500+

Re: "3D" gravity?

Daqa wrote:

wasabi56 wrote:

Okay, I get it now, you could have the 3 lanes be sprites and have:

<when [space v] key pressed>
perform jump you want

when gf clicked 
forever
if <touching [sprite 2 v]?>// lane #1
set [lane v] to(1)
end
if <touching [sprite 3 v]?>// lane #2
set [lane v] to(2)
end
if <touching [sprite 4 v]?>// lane #3
set [lane v] to(3)
end
If you need help with the actual gravity after this, just ask  smile

Alright, thank you. But how will Scratch understand "lane=1" means "jump from lane 1 and come back there"?

Would the different lanes be different colors?


http://i.picasion.com/pic58/c23d4d2fc75f459dcf3d9ebf3e8ba395.gif
http://www.weebly.com/uploads/1/0/1/4/10146167/2294523_orig.png

Offline

 

#11 2012-06-03 22:39:55

Daqa
New Scratcher
Registered: 2012-05-31
Posts: 10

Re: "3D" gravity?

wasabi56 wrote:

Daqa wrote:

wasabi56 wrote:

Okay, I get it now, you could have the 3 lanes be sprites and have:

<when [space v] key pressed>
perform jump you want

when gf clicked 
forever
if <touching [sprite 2 v]?>// lane #1
set [lane v] to(1)
end
if <touching [sprite 3 v]?>// lane #2
set [lane v] to(2)
end
if <touching [sprite 4 v]?>// lane #3
set [lane v] to(3)
end
If you need help with the actual gravity after this, just ask  smile

Alright, thank you. But how will Scratch understand "lane=1" means "jump from lane 1 and come back there"?

Would the different lanes be different colors?

I'm thinking in different colors, and then hiding the sprites behind a scenario.

Offline

 

#12 2012-06-03 23:06:27

wasabi56
Scratcher
Registered: 2012-02-10
Posts: 500+

Re: "3D" gravity?

Daqa wrote:

wasabi56 wrote:

Daqa wrote:

Alright, thank you. But how will Scratch understand "lane=1" means "jump from lane 1 and come back there"?

Would the different lanes be different colors?

I'm thinking in different colors, and then hiding the sprites behind a scenario.

Okay, then this might just work:

when gf clicked
forever 
if <<lane>=(1)>
if <touching color [color of lane #1]?>
change y by(5)
end
if <not<touching color[color of lane #1]?>>
change y by(-5)
end
end
if <<lane>=(2)>
if <touching color [color of lane #2]?>
change y by(5)
end
if <not<touching color[color of lane #2]?>>
change y by(-5)
end
end
if <<lane>=(3)>
if <touching color [color of lane #3]?>
change y by(5)
end
if <not <touching color [color of lane #3]?>>
change y by (-5)
end
end
Sorry I couldn't get the variables to work  sad
Tell me if this works or not  smile


http://i.picasion.com/pic58/c23d4d2fc75f459dcf3d9ebf3e8ba395.gif
http://www.weebly.com/uploads/1/0/1/4/10146167/2294523_orig.png

Offline

 

#13 2012-06-03 23:22:38

Daqa
New Scratcher
Registered: 2012-05-31
Posts: 10

Re: "3D" gravity?

wasabi56 wrote:

Daqa wrote:

wasabi56 wrote:


Would the different lanes be different colors?

I'm thinking in different colors, and then hiding the sprites behind a scenario.

Okay, then this might just work:

when gf clicked
forever 
if <<lane>=(1)>
if <touching color [color of lane #1]?>
change y by(5)
end
if <not<touching color[color of lane #1]?>>
change y by(-5)
end
end
if <<lane>=(2)>
if <touching color [color of lane #2]?>
change y by(5)
end
if <not<touching color[color of lane #2]?>>
change y by(-5)
end
end
if <<lane>=(3)>
if <touching color [color of lane #3]?>
change y by(5)
end
if <not <touching color [color of lane #3]?>>
change y by (-5)
end
end
Sorry I couldn't get the variables to work  sad
Tell me if this works or not  smile

Thanks a lot, but I'm not sure if this will work WITH jumping. I mean, you didn't include jumps in your script.
  But anyway it's givin a hint in this hard work.  wink

Offline

 

#14 2012-06-03 23:48:31

wasabi56
Scratcher
Registered: 2012-02-10
Posts: 500+

Re: "3D" gravity?

Daqa wrote:

wasabi56 wrote:

Daqa wrote:


I'm thinking in different colors, and then hiding the sprites behind a scenario.

Okay, then this might just work:

when gf clicked
forever 
if <<lane>=(1)>
if <touching color [color of lane #1]?>
change y by(5)
end
if <not<touching color[color of lane #1]?>>
change y by(-5)
end
end
if <<lane>=(2)>
if <touching color [color of lane #2]?>
change y by(5)
end
if <not<touching color[color of lane #2]?>>
change y by(-5)
end
end
if <<lane>=(3)>
if <touching color [color of lane #3]?>
change y by(5)
end
if <not <touching color [color of lane #3]?>>
change y by (-5)
end
end
Sorry I couldn't get the variables to work  sad
Tell me if this works or not  smile

Thanks a lot, but I'm not sure if this will work WITH jumping. I mean, you didn't include jumps in your script.
  But anyway it's givin a hint in this hard work.  wink

Well, jumping should work with it, because it's one of my platformer gravity (with jumping) scripts... sorry if it doesn't  hmm


http://i.picasion.com/pic58/c23d4d2fc75f459dcf3d9ebf3e8ba395.gif
http://www.weebly.com/uploads/1/0/1/4/10146167/2294523_orig.png

Offline

 

#15 2012-06-04 01:58:41

Daqa
New Scratcher
Registered: 2012-05-31
Posts: 10

Re: "3D" gravity?

wasabi56 wrote:

Daqa wrote:

wasabi56 wrote:


Okay, then this might just work:

when gf clicked
forever 
if <<lane>=(1)>
if <touching color [color of lane #1]?>
change y by(5)
end
if <not<touching color[color of lane #1]?>>
change y by(-5)
end
end
if <<lane>=(2)>
if <touching color [color of lane #2]?>
change y by(5)
end
if <not<touching color[color of lane #2]?>>
change y by(-5)
end
end
if <<lane>=(3)>
if <touching color [color of lane #3]?>
change y by(5)
end
if <not <touching color [color of lane #3]?>>
change y by (-5)
end
end
Sorry I couldn't get the variables to work  sad
Tell me if this works or not  smile

Thanks a lot, but I'm not sure if this will work WITH jumping. I mean, you didn't include jumps in your script.
  But anyway it's givin a hint in this hard work.  wink

Well, jumping should work with it, because it's one of my platformer gravity (with jumping) scripts... sorry if it doesn't  hmm

OK, I jump by pressin X. The problem with this script is that I got stuck in one lane, happens the same moving on y axis by jumping or by presing up arrow.
  BTW, what do u mean by "one of my platformer gravity (with jumping) scripts"?

Offline

 

#16 2012-06-04 09:29:22

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

Re: "3D" gravity?

See if this helps:

http://scratch.mit.edu/projects/amcerbu/1006552.

Use the arrow keys to move the ball left/right/up/down, and use the "w" and "s" keys to move it forward and backward. 

If you need me to explain the scripts, I can do that, but I want to make sure this what you're looking for first.

Offline

 

#17 2012-06-04 10:49:33

AtomicBawm3
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: "3D" gravity?

amcerbu wrote:

See if this helps:

http://scratch.mit.edu/projects/amcerbu/1006552.

Use the arrow keys to move the ball left/right/up/down, and use the "w" and "s" keys to move it forward and backward. 

If you need me to explain the scripts, I can do that, but I want to make sure this what you're looking for first.

This was one of the projects I was going to point you towards  smile .  I can't seem to find the others...but I can make an example for you since I'm pretty confident I understand what you want.


http://i50.tinypic.com/j0yw0p.jpg

Offline

 

#18 2012-06-04 10:52:26

wasabi56
Scratcher
Registered: 2012-02-10
Posts: 500+

Re: "3D" gravity?

Daqa wrote:

wasabi56 wrote:

Daqa wrote:


Thanks a lot, but I'm not sure if this will work WITH jumping. I mean, you didn't include jumps in your script.
  But anyway it's givin a hint in this hard work.  wink

Well, jumping should work with it, because it's one of my platformer gravity (with jumping) scripts... sorry if it doesn't  hmm

OK, I jump by pressin X. The problem with this script is that I got stuck in one lane, happens the same moving on y axis by jumping or by presing up arrow.
  BTW, what do u mean by "one of my platformer gravity (with jumping) scripts"?

Oh yeah, it occurs to me that the two scripts counteract each other...ummm maybe you could make the center of each lane a darker shade and have that be the landing place rather than the top of each lane...and not have the jump be high enough to touch the center of the next lane, and change the "touching sprite [ v]?" To "touching color [color of center of lane]"
P.S. I mean that it is my preferred gravity script for platformer games where you can jump.


http://i.picasion.com/pic58/c23d4d2fc75f459dcf3d9ebf3e8ba395.gif
http://www.weebly.com/uploads/1/0/1/4/10146167/2294523_orig.png

Offline

 

#19 2012-06-04 11:07:02

AtomicBawm3
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: "3D" gravity?

Oh wait, found one: http://scratch.mit.edu/projects/Kileymeister/1413602

EDIT: and here's mine: http://scratch.mit.edu/projects/A__B__3 … _T/2587189

Last edited by AtomicBawm3 (2012-06-04 11:23:40)


http://i50.tinypic.com/j0yw0p.jpg

Offline

 

#20 2012-06-06 22:45:55

Daqa
New Scratcher
Registered: 2012-05-31
Posts: 10

Re: "3D" gravity?

Sorry I was online a long time. Just that.
        Now I'll check  the nice stuff! Thax all!

Offline

 

#21 2012-06-06 22:55:51

Daqa
New Scratcher
Registered: 2012-05-31
Posts: 10

Re: "3D" gravity?

Checkin' "Help for Daqa".
  First, I think it can help A LOT of people, not just me. Second, I'll have to open and view the project many and many times (in order to adapt it to my game) coz involves a lot of deep thinking to understand, ha-ha-ha!

Offline

 

Board footer