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]
Offline
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.
Offline
Here is a pleasant collision tutorial which explains one of the many methods. http://scratch.mit.edu/projects/fireball123/940816
Offline
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.
Offline
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)
Offline
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
Offline
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
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
Offline
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.
Offline
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
Offline
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]
Offline
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
Offline
Make the walls a color.
Offline
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
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
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
Check this out:
http://scratch.mit.edu/projects/project1/1234179
Its a platformer engine by me(my test account.)
Offline
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