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

#1 2011-11-16 22:00:03

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

A Response

The following is a response I have towards a Scratcher's project (here).  For lack of a better category, I'm putting it here.  I'm posting it on the forums because the comments simply aren't a plausible method of conveying my message:


Not too shabby for your first 1s1s and your second platformer.  Of course the obvious criticism is "add more levels".  I hate level design as much as the next guy, but to have a good game, you need a fair amount of levels.  I've got a game or two online that I really should have waited to upload until I had added some levels.  On the bright side, there don't appear to be any bugs.  In a platformer, that is never easy, particularly a 1s1s.

Enough about the game's properties, lets get into the script.  I noticed that you've shaped your code around the variable "My personal level".  The code is set to work given a certain value.  This works to a certain extent - you employ it quite successfully - but in terms of efficiency (not for the program, but for you, the programmer), there are ways to improve.

This may be egotistical, but lets look at how I code.  Most - if not all - of my 1s1s platformers have one movement section of code.  You use two, one for each level.  This works fine for a game with two levels, but for every level you add, you'll need to add 23 blocks (if my counting is correct).  If you want to make a game with more levels (10 is my general rule of thumb), you don't want to have to have 230 blocks for movement.  The solution I use is that movement isn't within a "if" block.  In other words, I run through it every frame (see note at bottom*), regardless of what is happening in the game.  I don't have a variable like your "My personal level" variable.  Here is a basic format of my code:

It is important to note that even this code is updated from my other projects.  You should always be trying to improve your script.  Take a look at my platformers to see how they've evolved, from requiring a "floor color" and a "wall color" with static velocity to using x-velocity and y-velocity and being able to handle a uniform color.

Code:

[When Green Flag Clicked]
set [makelevel] to (1)
[forever]
     if(makelevel = 1)        // if I need to render a level
     {
          if(level = 1)
          {
               [make level 1]
          }
          else
          {
               if(level = 2)
               {
                    [make level 2]
               }
               else
               {
                    [make level 3]
               }
          }
          set [makelevel] to (0)
     }

     [movement script]        // always runs

     if touching goal
     {
          change [level] by (1)
          set [makelevel] to (1)
     }
     if touching red
     {
          set [makelevel] to (1)
     }

If we carefully analyze the script, we see that, whenever "makelevel" is equal to 1, we make the level and set "makelevel" back to 0.  That way, whenever we want to restart the level, we just have to set "makelevel" to 1.  If we want to go onto the next level, we just change level by 1, and set "makelevel" to 1.  The computer doesn't care if we're restarting or moving onto the next level, it just renders the level.  It is important to know that, if you're making more complex levels, simply stamping a background and the platforms won't be enough, and you may need to complicate your script.

Okay, I'm going to stop criticizing your script now.  Overall, a very good platformer.  You coded in a way that worked for the game you were making, and that, above all, is the most important thing.  I'm going to leave you with a challenge.  Try to create a platformer (it doesn't have to be 1s1s) that has walls, in addition to a floor.  You'll need to develop a method to sense whether there is a wall on your left, your right, and below you, and base your movement of of whether a direction is "free" or "occupied".  Get this going, and you'll be able to create walls, a necessary tool in any game-maker's belt.

* Every time your "forever" loop is run through, I consider it a frame.  This isn't common terminology, it is terminology that I have made up.


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#2 2011-11-24 14:16:37

nightmarescratcher
Scratcher
Registered: 2011-10-10
Posts: 1000+

Re: A Response

*clap*


http://fc07.deviantart.net/fs70/f/2011/171/f/3/derpy_hooves_derp_sig_by_alicehumansacrifice1-d3jg613.png

Offline

 

#3 2011-11-24 15:09:15

Lar-Rew
Scratcher
Registered: 2010-02-19
Posts: 100+

Re: A Response

Very nice MoreGamesNow.  Reusing code is great.  Note that rightclick-copy works, it's just annoying.

Last edited by Lar-Rew (2011-11-24 15:09:46)

Offline

 

Board footer