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

#1 2010-08-09 13:04:54

murpho
Scratcher
Registered: 2010-07-01
Posts: 1000+

Better collision script

I have an idea for a collision script and i thout this would work

wall script:
[blocks]
<when green flag clicked>
<set{ collision }to( 0
<forever>
<if><<  <not>  >><touching[ character
<set{  }to( 0
<if><touching[ character
<set{  }to( 1

Character script:
<when green flag clicked>
<forever>
<if><( <{ collision }> <>> 0 )>
<change x by( 0
<change y by( 0
[/blocks]


https://lh6.googleusercontent.com/-l-rgCPiQ9pY/Tp32n1MRUEI/AAAAAAAADoA/HNQWbO8OOaA/s510/soccerleague.gif

Offline

 

#2 2010-08-09 14:31:27

murpho
Scratcher
Registered: 2010-07-01
Posts: 1000+

Re: Better collision script

plz answer


https://lh6.googleusercontent.com/-l-rgCPiQ9pY/Tp32n1MRUEI/AAAAAAAADoA/HNQWbO8OOaA/s510/soccerleague.gif

Offline

 

#3 2010-08-09 14:50:10

Telemachus
Scratcher
Registered: 2010-04-21
Posts: 500+

Re: Better collision script

The problem with this is that the "change x by 0" and "change y by 0" scripts in effect do nothing, because other scripts will still have an effect on x and y movement.


http://i54.tinypic.com/10h0fnp.jpg

Offline

 

#4 2010-08-09 15:21:36

murpho
Scratcher
Registered: 2010-07-01
Posts: 1000+

Re: Better collision script

I dot know collision really so like... Just trying to learn a better way with out color collision because then i can't use that color for anything but collision


https://lh6.googleusercontent.com/-l-rgCPiQ9pY/Tp32n1MRUEI/AAAAAAAADoA/HNQWbO8OOaA/s510/soccerleague.gif

Offline

 

#5 2010-08-09 15:27:32

Telemachus
Scratcher
Registered: 2010-04-21
Posts: 500+

Re: Better collision script

Here is a pleasant collision tutorial which explains one of the many methods. http://scratch.mit.edu/projects/fireball123/940816


http://i54.tinypic.com/10h0fnp.jpg

Offline

 

#6 2010-08-09 16:19:38

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Better collision script

I don't really see the point of this... you could just have a single script on the character with If <touching sprite 1> or <touching sprite2> or <touching sprite3> etc... Less scripts, variables, etc.


http://www.blocks.scratchr.org/API.php?action=random&amp;return=image&amp;link1=http://i.imgur.com/OZn2RD3.png&amp;link2=http://i.imgur.com/duzaGTB.png&amp;link3=http://i.imgur.com/CrDGvvZ.png&amp;link4=http://i.imgur.com/POEpQyZ.png&amp;link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#7 2010-08-09 17:51:03

murpho
Scratcher
Registered: 2010-07-01
Posts: 1000+

Re: Better collision script

Yeah but i would have to make one for EVERY SINGLE WALL and im making a RPG so that would take forever and cause lag


https://lh6.googleusercontent.com/-l-rgCPiQ9pY/Tp32n1MRUEI/AAAAAAAADoA/HNQWbO8OOaA/s510/soccerleague.gif

Offline

 

#8 2010-08-09 20:03:36

tikktokk
Scratcher
Registered: 2009-08-21
Posts: 30

Re: Better collision script

I guess if you Are using direction, move X steps. you can make a direction variabel. And when touching "wall": set "varable direction" to direction of sprite and then set direction of sprite to direction direction of sprite - variabel direction (make it Face oposit direction) and move x steps!

And if you use "change x by" and "change y by" you can make x and y variabels and set them the x variabel to xvarabel * -1 make it move oposit direction agien and same With y variabel

Last edited by tikktokk (2010-08-09 20:06:41)


Vigenère cipher, the unbreakable code system! so strong not even the strongest computer can break it! you can mail people secrets you dont want other to know! and all this here!

Offline

 

#9 2010-08-09 22:58:59

murpho
Scratcher
Registered: 2010-07-01
Posts: 1000+

Re: Better collision script

Confusing


https://lh6.googleusercontent.com/-l-rgCPiQ9pY/Tp32n1MRUEI/AAAAAAAADoA/HNQWbO8OOaA/s510/soccerleague.gif

Offline

 

#10 2010-08-10 09:00:35

chipguy
Scratcher
Registered: 2009-09-09
Posts: 500+

Re: Better collision script

murpho wrote:

I have an idea for a collision script and i thout this would work

wall script:
[blocks]
<when green flag clicked>
<set{ collision }to( 0
<forever>
<if><<  <not>  >><touching[ character
<set{  }to( 0
<if><touching[ character
<set{  }to( 1

Character script:
<when green flag clicked>
<forever>
<if><( <{ collision }> <>> 0 )>
<change x by( 0
<change y by( 0
[/blocks]

technichly you can do if else instead of to ifs


http://scratch.mit.edu/static/projects/chipguy/2919121_sm.png by yours truly  big_smile

Offline

 

#11 2010-08-10 09:02:10

MabonBaladevaKain
Scratcher
Registered: 2010-07-25
Posts: 80

Re: Better collision script

I'm a newbie here in the world of Scratch, but ....
I have something in mind for this.
I'll start working on an example for you after I finish my first Scratch project.

Offline

 

#12 2010-08-10 10:13:41

murpho
Scratcher
Registered: 2010-07-01
Posts: 1000+

Re: Better collision script

MabonBaladevaKain wrote:

I'm a newbie here in the world of Scratch, but ....
I have something in mind for this.
I'll start working on an example for you after I finish my first Scratch project.

I know i can use else if. Im just trying to give an example. Its more important than you think. Its for a major RPG im working on


https://lh6.googleusercontent.com/-l-rgCPiQ9pY/Tp32n1MRUEI/AAAAAAAADoA/HNQWbO8OOaA/s510/soccerleague.gif

Offline

 

#13 2010-08-10 14:40:14

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Better collision script

murpho wrote:

Yeah but i would have to make one for EVERY SINGLE WALL and im making a RPG so that would take forever and cause lag

A single <If touching _> for every wall in a single conditional is better than an entire script in every single wall, in my opinion. But hey, that's just me.


http://www.blocks.scratchr.org/API.php?action=random&amp;return=image&amp;link1=http://i.imgur.com/OZn2RD3.png&amp;link2=http://i.imgur.com/duzaGTB.png&amp;link3=http://i.imgur.com/CrDGvvZ.png&amp;link4=http://i.imgur.com/POEpQyZ.png&amp;link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#14 2010-08-10 18:18:21

murpho
Scratcher
Registered: 2010-07-01
Posts: 1000+

Re: Better collision script

Harakou wrote:

murpho wrote:

Yeah but i would have to make one for EVERY SINGLE WALL and im making a RPG so that would take forever and cause lag

A single <If touching _> for every wall in a single conditional is better than an entire script in every single wall, in my opinion. But hey, that's just me.

Maybe but im not entirely sure im gonna try my variable one first


https://lh6.googleusercontent.com/-l-rgCPiQ9pY/Tp32n1MRUEI/AAAAAAAADoA/HNQWbO8OOaA/s510/soccerleague.gif

Offline

 

#15 2010-08-10 18:26:51

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Re: Better collision script

murpho wrote:

I have an idea for a collision script and i thout this would work

wall script:
[blocks]
<when green flag clicked>
<set{ collision }to( 0
<forever>
<if><<  <not>  >><touching[ character
<set{ collusion }to( 0
<if><touching[ character
<set{ collusion }to( 1

Character script:
<when green flag clicked>
<forever>
<if><( <{ collision }> <>> 0 )>
<change x by( 0
<change y by( 0
[/blocks]


You can now reach me on Twitter @johnnydean1_

Offline

 

#16 2010-08-10 18:48:24

murpho
Scratcher
Registered: 2010-07-01
Posts: 1000+

Re: Better collision script

johnnydean1 wrote:

murpho wrote:

I have an idea for a collision script and i thout this would work

wall script:
[blocks]
<when green flag clicked>
<set{ collision }to( 0
<forever>
<if><<  <not>  >><touching[ character
<set{ collusion }to( 0
<if><touching[ character
<set{ collusion }to( 1

Character script:
<when green flag clicked>
<forever>
<if><( <{ collision }> <>> 0 )>
<change x by( 0
<change y by( 0
[/blocks]

Umm


https://lh6.googleusercontent.com/-l-rgCPiQ9pY/Tp32n1MRUEI/AAAAAAAADoA/HNQWbO8OOaA/s510/soccerleague.gif

Offline

 

#17 2010-08-10 18:54:24

Billybob-Mario
Scratcher
Registered: 2008-01-05
Posts: 500+

Re: Better collision script

Make the walls a color.

Offline

 

#18 2010-08-10 19:08:14

murpho
Scratcher
Registered: 2010-07-01
Posts: 1000+

Re: Better collision script

Billybob-Mario wrote:

Make the walls a color.

Im trying to do it with out a color collision script


https://lh6.googleusercontent.com/-l-rgCPiQ9pY/Tp32n1MRUEI/AAAAAAAADoA/HNQWbO8OOaA/s510/soccerleague.gif

Offline

 

#19 2010-08-11 20:22:13

MabonBaladevaKain
Scratcher
Registered: 2010-07-25
Posts: 80

Re: Better collision script

As I said before, I will make an example on exactly how to do this.
I'm almost finished with my first game in Scratch. Be patient please.
I doubt that it's any different than I believe it to be, but we'll cross that bridge when
we get there.

I'm almost finished with my first project, all I have to do is make a title screen and
then try to upload the game onto the Scratch site.

<thoughts on Scratch so far below>
If Scratch didn't lag so much with a single large script then I would have been done the first or second day, but I was held up by the glitchy Scratch interface.
The speed issues and no real copy/paste are the only downfalls I see with using Scratch, and I think that once I start making something using more than a single HUGE script, the speed trouble regarding the interface should subside (I hope), and the runtime speed may not even be an issue for me depending on what I code.

Offline

 

#20 2010-08-11 20:33:19

murpho
Scratcher
Registered: 2010-07-01
Posts: 1000+

Re: Better collision script

Thanks


https://lh6.googleusercontent.com/-l-rgCPiQ9pY/Tp32n1MRUEI/AAAAAAAADoA/HNQWbO8OOaA/s510/soccerleague.gif

Offline

 

#21 2010-08-11 22:37:41

MabonBaladevaKain
Scratcher
Registered: 2010-07-25
Posts: 80

Re: Better collision script

I'm finished now Yay! ... I'm gonna start on that example for you now.
It always takes me a while to do any kind of pixel art, sorry for that.

Could you do me a favor and see if my project is working? .. I just uploaded it.
I'm curious how well it runs online, seeing as how it uses a huge single script.
If it don't work online lemme know an' just download it.
Thank You!

I should have that example done for you by tomorrow, maybe sooner.

Offline

 

#22 2010-08-11 22:39:53

murpho
Scratcher
Registered: 2010-07-01
Posts: 1000+

Re: Better collision script

Cool!!! Thanks!!!!


https://lh6.googleusercontent.com/-l-rgCPiQ9pY/Tp32n1MRUEI/AAAAAAAADoA/HNQWbO8OOaA/s510/soccerleague.gif

Offline

 

#23 2010-08-12 10:22:32

MabonBaladevaKain
Scratcher
Registered: 2010-07-25
Posts: 80

Re: Better collision script

It's ridiculous how bad the collision control is in Scratch.
I'm trying to stay optimistic but so far I haven't figured out any near perfect solution.

I've made several attempts though, but I'm not satisfied with any yet.
I'll upload one so you at least have something to look at, but I'll need to tinker with them later.
Need sleep right now.

Offline

 

#24 2010-08-12 10:28:32

laser100
Scratcher
Registered: 2009-12-04
Posts: 100+

Re: Better collision script

Check this out:
http://scratch.mit.edu/projects/project1/1234179


Its a platformer engine by me(my test account.)

Offline

 

#25 2010-08-12 20:31:40

MabonBaladevaKain
Scratcher
Registered: 2010-07-25
Posts: 80

Re: Better collision script

Meh, checked it out, it's ok but looks similar to what I've seen already and It doesn't answer his question.

Mine does answer his question in that it provides a script that all he has to do is drag it to any new wall sprite that he creates and he's good to go.
Btw, I don't have Java installed, so I have no clue how the stuff I've made so far works online. Let me know if anything doesn't work right please.

Murpho, if you haven't noticed yet, the example I made you is here:
http://scratch.mit.edu/projects/MabonBaladevaKain/1242143

It's about as good as the other collisions I've seen, but it does have a glitch where you can move through walls if you hit in a certain way and press certain keys at the right time. Let me know if it works ok online or not.
Most importantly though, it answers your question.

Offline

 

Board footer