This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.
  • Index
  •  » Project Ideas
  •  » What you think of this idea as a game? How would i go about it??

#1 2010-05-21 14:33:10

action9
Scratcher
Registered: 2010-05-21
Posts: 2

What you think of this idea as a game? How would i go about it??

I want to create a program which dynamically creates a grid similar to the one shown in the diagram. The number of rows should be chosen using a random number generator. The number of columns should also be chosen using a random number generator.
The arrow should be initially positioned in the bottom left position on the grid. The arrow should be programmed to move in accordance with the instructions that will be placed into a textbox at the bottom of the screen at runtime. Once the button “Go!” is pressed, the animation of the arrow should begin. This should proceed at a pace that allows the user to observe each step of the arrows motion.
The arrow is only allowed to visit the white boxes.  Vertical, horizontal and diagonal movements are permitted. Should the arrow reach blue box, an error message should be displayed and the arrow should return to its starting position.
o    The movement control language is made up of three commands: Ln, Rn and Fn.,
o    Ln means turn the arrow left (anticlockwise) through n positions, where n is an integer (whole number).
o    Rn means turn the arrow right (clockwise) through n positions, where n is an integer (whole number).
o    Fn means move the arrow forward through n positions, where n is an integer (whole number).
o    A sample command might be R2F3L2F1R2F4.

What you think of this idea as a game? Any idea of how i could go about starting it?

HERE is the Diagram:
http://www.sebb.co.cc/a.jpg

Offline

 

#2 2010-05-21 16:59:58

JSO
Community Moderator
Registered: 2007-06-23
Posts: 1000+

Re: What you think of this idea as a game? How would i go about it??

Ok, first, I guess you want to make a Scratch project out of this and not a java program...

Also, is this a homework assignment? Because it sort of seems like one... If it is we can still help you, but it's a bit unfair to make the whole game for you right?

You want to start of building the grid. That's easy, first draw all vertical lines, then all horizontal ones. Every column has the with of screenwidth(480px)/#columns, every row has a height of screenheight(360px)/#rows. Remember to "clear" before you start drawing. (more later)


http://oi48.tinypic.com/2v1q0e9.jpg

Offline

 

#3 2010-05-22 04:40:34

action9
Scratcher
Registered: 2010-05-21
Posts: 2

Re: What you think of this idea as a game? How would i go about it??

Its an game which i want to make for my son,to practice he's skills of predictibility. I am a Child Psychologist with some programming knowledge.

I downloaded the instructions from the internet so maybe thats why it could be sounding like an assignment.

About the grid,With scratch do i use multi dimensional arrays or what? What is scratch exactly? Would you know how i would go about randomly generating those blue boxes and making the arrow walk from one corner to the next?

Offline

 

#4 2010-05-22 05:26:41

Jonathanpb
Scratcher
Registered: 2008-07-25
Posts: 1000+

Re: What you think of this idea as a game? How would i go about it??

Your questions:
• Scratch doesn't have multi-dimensional arrays. We have one-dimensional lists, which are similar to one-dimensional arrays.
Scratch is the Scratch programming language that this site is for. Do you have Scratch installed on your computer? If not, get it here.
• For generating the grid shape, you could make a sprite that looks like one of the cells, and then have it stamp itself all over the screen to create a grid. To make a row of cells, have the sprite at the left side of the screen, stamp it, move it so it's on the right of the stamp, stamp it again, and repeat till you've stamped across the screen. To make the full grid, just make several rows of cells, stacked on each other.
• For making the map, give the stamping sprite two costumes - one a white box, one a blue box. Before the sprite stamps each time, set a variable randomly from one value to another (I'll go with 1 - 4). If the value equals 1, change the box's costume to the blue box - if it's not 1, change its costume to the white box. With this, you'll get a random layout. There's a problem though - there's no guarantee that you won't be trapped in one corner of the map; there could be a wall that prevents you from moving around the map. If you want to avoid that, don't ask me - I don't know how! Ask in All About Scratch.
• For moving the arrow, set a variable to 0. Then continuously do this until all moves have been completed: Change the variable by 1, look at the letter and figure out what direction the arrow must move in, then change the variable by 1 again and record the number, then move the arrow in the recorded direction with the recorded amount of 'steps'.

Hope I helped!  smile

Last edited by Jonathanpb (2010-05-22 05:28:24)


"Human beings... must have action; and they will make it if they cannot find it.
-Charlotte Brontë

Offline

 
  • Index
  •  » Project Ideas
  •  » What you think of this idea as a game? How would i go about it??

Board footer