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.
Offline
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
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.
Offline
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
Last edited by archmage (2010-06-30 12:39:00)
Offline