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

#1 2010-06-28 15:24:37

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

review the code in "Mario RPG_revised"

This is meant to be a sample project for a guide on the scratch wiki. Some users have said that the scripts could be made better.

http://scratch.mit.edu/projects/archmage/1156402

Here is the psuedocode:

1. Game state at 1, wait for user to select an option then set game state to 2 (player character action)
2. A broadcast is sent which does the appropriate damage calculation and triggers an animation of the player sprite
3. After the animation of the player sprite, game state is set to 3 which triggers the enemy's actions.
4. The enemy picks a random attack then sets the game state to 0 (to wait to be reset to 1)
5. The enemy finishes his action and deals damage. The game state is set to 1 and this loops until one character has their HP (health points)<1.


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#2 2010-06-28 19:19:43

12three
Scratcher
Registered: 2008-06-12
Posts: 1000+

Re: review the code in "Mario RPG_revised"

Long time, no see.
This project seems cool, so I'm going to download it and see if I can learn something from the scripting.

Offline

 

#3 2010-06-29 23:21:45

mkolpnji
Scratcher
Registered: 2007-07-20
Posts: 100+

Re: review the code in "Mario RPG_revised"

The only thing I can think of changing is that to make all of the broadcasts for the player character into one broadcast called action and adding if else blocks into the code to make it different for whatever action the player is taking. You should also combine the enemy broadcasts.

And you could always make lists for character animations. Such as c_anistartsprite where the 1st entry would be the starting animation for the regular attack, and so on. An then make a c_aninumofsprites where the 1st entry would be the amount of sprites in the animation for the regular attack. I used it in my current beta for Phoenix Wright (Which I havn't updated in a long time) and it helps reduce script length by a lot.


http://i723.photobucket.com/albums/ww232/mkolpnji/signaturebanner.gif

Offline

 

#4 2010-06-30 12:34:57

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: review the code in "Mario RPG_revised"

You have some good points mkolpnji. When I was thinking on how to code this I first thought of how I would make it in flash and then how would it translate into scratch. The actions for the character would probally be contained in a function called PlayerAction which accepts the following perameters :action type, actionID. The action type would indicate what type of action and the actionID would let the function know the properties of each unique action. After the function gets the actionID variable it would look up the properties (including, animation, damage/healing, mana cost, and others) of the action in a set of multidimentional arrays (1 multidimentional-array per action type). This sort of coding can't be perfectally put in scratch code so I had to imporvise. Also, I kept in mind that that kind of coding is for more large scale games and scratch cannot handle large programs. In the scratch program each action type there is 1 broadcast and there is only 1 unique attack of each type.

The reasons for using broadcasts in the way I did are:
-Improve noobie friendlyness (its easier to see the individual scripts and their functions)
-Reduce variables
-Avoid using long scripts (avoid lag in the editor)
-The old mario rpg which I based off a flash engine was already set up with broadcasts (lazyness on my part)

I will try combining the broadcasts to see how that works out. If it doesn't make things sufficiently better I will probally leave things as they are for simplicity.

As for animations, it isn't as simple as making a list of numbers becuase the sprites change costumes and move.


Thanks a lot for the input  smile

Last edited by archmage (2010-06-30 12:39:00)


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

Board footer