Discuss Scratch

Teleporter
New to Scratch
9 posts

RPG Attack and Solid Objects

Hello, firstly I'd like to get this out of the way, I'm new to Scratch. In school I am making a RPG and it uses a semi bird's-eye-view perspective (similar to the original Legend of Zelda). I have the scroll to work properly but I have a few questions on things regarding this. How would I go about making a solid object so that when you go into it, and continue holding the movement keys, the screen doesn't continue scrolling an neither does the player? Secondly, I am trying to make it so when you go within a certain proximity to a sprite, it starts to talk(keep in mind I am using scroll X and scroll Y). Lastly, I would like to make monsters that move about by themselves randomly and perhaps go within a certain proximity of the character you control, it gravitates towards you. And not only this, it damages you when it comes into contact (again, similar to the original Zelda) and you can attack it back and damage the monster. I realize this is a lot of things I want, but I am sure it is possible and I have no clue how to go about doing it. Thanks in advance.

With regards,
Teleporter
JayZX535
Scratcher
62 posts

RPG Attack and Solid Objects

Teleporter wrote:

Hello, firstly I'd like to get this out of the way, I'm new to Scratch. In school I am making a RPG and it uses a semi bird's-eye-view perspective (similar to the original Legend of Zelda). I have the scroll to work properly but I have a few questions on things regarding this. How would I go about making a solid object so that when you go into it, and continue holding the movement keys, the screen doesn't continue scrolling an neither does the player? Secondly, I am trying to make it so when you go within a certain proximity to a sprite, it starts to talk(keep in mind I am using scroll X and scroll Y). Lastly, I would like to make monsters that move about by themselves randomly and perhaps go within a certain proximity of the character you control, it gravitates towards you. And not only this, it damages you when it comes into contact (again, similar to the original Zelda) and you can attack it back and damage the monster. I realize this is a lot of things I want, but I am sure it is possible and I have no clue how to go about doing it. Thanks in advance.

With regards,
Teleporter
Hm… this is quite similar to my game Dark Realms.
First of all you need to create an AI for the enemies (for now just sprite one- then you can duplicate the sprite and make whatever alterations to costumes to make different monsters that you need). I am assuming that you want attack-on-sight enemies? For now let's say that the enemy attacks at 150 distance from the player.
Creating an enemies AI:
Variables needed:
Direction variable* (for now let's call it “direction”)

*This is very important unless you are using a completely overhead view, because if you don't simply want to rotate the sprite, you need a way of distinguishing between up, down, and side walk cycles (side walk cycles can be reversed if the direction-changing ability of a sprite is set to right-left).
1. Add the following code to the enemy's sprite:
When green flag clicked
Set direction to (pick random 1 to 4) NOTE: Normal direction-changing (R-L) will be listed as “direction***”
Forever
If (distance to player) < 150
–LEAVE THIS BLANK FOR NOW!!!–
Else
If direction = 1
*enter whatever code you have for the up walk cycle here*
Else
If direction = 2
*enter whatever code you have for the down walk cycle here*
Else
If direction = 3
Set direction*** to 90
*enter whatever code you have for the side walk cycle here*
Else
If direction = 4
Set direction*** to -90
*enter whatever code you have for the side walk cycle here*

2. Add this code into the “If distance to player < 150” section, where I put –LEAVE THIS BLANK FOR NOW–:
Walk (round (distance to player/30)) seconds to x (x position of player) y (y position)
Walk (round (distance to player/30) seconds to x (x position) y (y position of player)
*add whatever code you need to attack*

Do you need help with programming the character's action too? If so, let me know.
Hope this helped!
-Jay
Teleporter
New to Scratch
9 posts

RPG Attack and Solid Objects

I can't seem to get it to work. I either got the code wrong, this doesn't work, or it doesn't work whilst using scroll X and Y. When I press the green flag, the enemy spawns somewhere completly random, and his “direction” only gets chosen at random one time, not constantly. Could you get a picture of how the code looks? I will also need help with the characters attacking the enemy, and the enemy attacking the character.
JayZX535
Scratcher
62 posts

RPG Attack and Solid Objects

Teleporter wrote:

I can't seem to get it to work. I either got the code wrong, this doesn't work, or it doesn't work whilst using scroll X and Y. When I press the green flag, the enemy spawns somewhere completly random, and his “direction” only gets chosen at random one time, not constantly. Could you get a picture of how the code looks? I will also need help with the characters attacking the enemy, and the enemy attacking the character.

Gah. That would be my fault. Sorry.
CORRECTED CODE (step 1):
If (distance to player) < 150–LEAVE THIS BLANK FOR NOW!!!–
Else
If direction = 1 *enter whatever code you have for the up walk cycle here*
Else
If direction = 2 *enter whatever code you have for the down walk cycle here*
Else
If direction = 3
Set direction*** to 90 *enter whatever code you have for the side walk cycle here*
Else If direction = 4
Set direction*** to -90 *enter whatever code you have for the side walk cycle here*
Set direction to (pick random 1 to 4)

Sorry, that was completely my fault! And don't forget to enter the enemy's spawn point before the code starts.
E.g.:
When green flag clicked
Go to x (starting x position) y (starting y position)
And sorry- I can't do pictures.
Do you have the sprites? If you can post them up, I can make a beta for you with the coding since it's a bit hard to explain.
Can you tell me what kind of attacking you want (e.g. random chance of dealing uber-damage, rpg style of picking attacks with different strengths and weaknesses, etc)?

Last edited by JayZX535 (May 30, 2013 16:52:47)

Teleporter
New to Scratch
9 posts

RPG Attack and Solid Objects

I can't edit my post, but I made a mistake. The enemy doesn't spawn in a random area, my sprite was just messed up. But how would I go about setting him in an area (say 200x200) and he can't leave that area, but the main character can? Or perhaps the character can “shake” the enemy off, because currently, he runs faster than I do. The character doesn't move at all, and since I'm using scroll X+Y, everything moves around him, and when I try to run away from the monster, he scrolls with me. Any thoughts?
JayZX535
Scratcher
62 posts

RPG Attack and Solid Objects

Ohhhhh, I see! You need to make an X position variable and a Y position variable. Then if the monster's position of the x variable is on the screen, he'll go to that x position, but if it isn't, he'll hide and won't be reactive. It's sort of hard to explain, but I've done that kind of thing before (just haven't quite finished them because I'm not done spriting). So yeah, if you can get me the sprites, I can script it for you and then you can see what I did (and make changes, etc.)
Teleporter
New to Scratch
9 posts

RPG Attack and Solid Objects

Sounds good, currently I'm at school so I can't. I will in roughly 5 hours.
JayZX535
Scratcher
62 posts

RPG Attack and Solid Objects

OK, I'll check for you then
Teleporter
New to Scratch
9 posts

RPG Attack and Solid Objects

I couldn't get the images formatted properly, but their are only four different ones (the four in the middle in a 2x2 arrangement) and the rest are just the same thing but inverted.
JayZX535
Scratcher
62 posts

RPG Attack and Solid Objects

KK, I'll go look
JayZX535
Scratcher
62 posts

RPG Attack and Solid Objects

Hey, did you post up the sprites? Because I couldn't find them…
Teleporter
New to Scratch
9 posts

RPG Attack and Solid Objects

http://imageshack.us/content_round.php?page=done&id=4tHcnJqkm6Gpk-TZ0OXd2-vQ2cjZ2NPV3tej09na My bad, I thought I linked it in my post.
JayZX535
Scratcher
62 posts

RPG Attack and Solid Objects

Can you post them on here in a project so I can just remix?
Teleporter
New to Scratch
9 posts

RPG Attack and Solid Objects

http://scratch.mit.edu/projects/10568549/ Don't mind the aesthetics right now, I'll fix it later.
JayZX535
Scratcher
62 posts

RPG Attack and Solid Objects

KK, thanks! I'll get working!
Pixelist
New to Scratch
1 post

RPG Attack and Solid Objects

Hey, are you going to share this project because I would really like to get my hands on this script, also why did you not answer his other questions, because I have all the same questions too.
vidarfw02
Scratcher
100+ posts

RPG Attack and Solid Objects

Hi, I use a list to store all tiles of the dungeon. Then make a look up into the table every time a plyer moves to see if the tile he is trying to move to is solid or not.

In this project I think you will see suggestions to solve all your questions above….it even has a nice Zelda sprite

http://scratch.mit.edu/projects/23708468

If any of my methods are intereseting….just ask and I will try to answer to the best of my abilities. Scratch needs more good RPG games!

If you go into the “blocks” sprite…you will see a large table…if you change the numbers in there…you will change that specific tile of the dungeon. The table is placed out just like the dungeon. If you go to the item placer sprite you will find the same table…but this time its for placing items…

Try writing some “40” in the first large table in the “item placer” sprite close to where you start…and you will get more healing potions




Last edited by vidarfw02 (Oct. 5, 2014 21:49:01)



Powered by DjangoBB