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

#1 2012-12-21 14:02:48

iEcoWarrioR
New Scratcher
Registered: 2012-12-18
Posts: 20

help with 2d casual shooter

I am making a 2D casual shooter, but I have a problem.
I drew a sprite that is the map of a lvl (the walls)
But how can I make that the sprite that you move, if he touches the wallsprite, he bounces, and that the sprite that moves can't walk true the wallsprite?
Thanks for your help

Offline

 

#2 2012-12-22 03:51:59

mrn0body
Scratcher
Registered: 2012-12-11
Posts: 37

Re: help with 2d casual shooter

Make a sprite with a different colour on each side and put this as its script. Also make four variables called left, right, up and down
? is the colour of the right side of the sprite
! is the wall colour

when gf clicked
forever
if <colour (?) touching colour (!)
set [right v] to <yes>
else
set [right v] to <no>
end
end
Do the same for left, up and down but with the different colours. Then put this as your moving script on the player

when gf clicked
forever
if <<key [right arrow v] pressed and (right) = [no]>
change x by [10]
end
end
Again do the same with left, right and up. I hope this helps!  smile


Why Fit In When You Were Born To Stand Out

Offline

 

#3 2012-12-22 04:45:00

iEcoWarrioR
New Scratcher
Registered: 2012-12-18
Posts: 20

Re: help with 2d casual shooter

mrn0body wrote:

Make a sprite with a different colour on each side and put this as its script. Also make four variables called left, right, up and down
? is the colour of the right side of the sprite
! is the wall colour

when gf clicked
forever
if <colour (?) touching colour (!)
set [right v] to <yes>
else
set [right v] to <no>
end
end
Do the same for left, up and down but with the different colours. Then put this as your moving script on the player

when gf clicked
forever
if <<key [right arrow v] pressed and (right) = [no]>
change x by [10]
end
end
Again do the same with left, right and up. I hope this helps!  smile

I fixed it already, but thanks for the help.  tongue

Offline

 

Board footer