Small Basic Challenge of the Week 9 (26 August - 1 September)

General discussion

• Welcome to the 'SmallBasic Challenge of the Week'.  This is just a suggestion for a programming project where users can contribute their solutions/ideas and help each other.  There are no prizes and the only rule really is to use standard SmallBasic methods (no extensions). Post solutions/help on this thread that will remain 'sticky' for about one week before we move onto the next. Please also give any suggestions for a future 'Challenge of the Week' or general feedback on the type of challenges you would like to see.

Week 9 (August 26th - September 1st, 2011)

Easy Challenge (For the absolute beginner to programming)

Write a Text Window program that asks the user for a width and height. The program will then draw a rectangle with these dimensions using asterisks (*)

Example:
```What is the width?
10
What is the height?
5
**********
**********
**********
**********
**********
```

Intermediate Challenge (For people with some programming knowledge)

Write a program that allows you to move a graphic around the screen (up, down, left and right) by using the arrow keys. The graphic should always face the direction that it is moving. When the space bar is pressed the graphic should shoot a bullet in the direction that it is facing.

Advanced Challenge (You are doing very well if you can do this!)

Write a program to draw the Sierpinski Triangle fractal shown below. There are various algorithms that can be used. See http://en.wikipedia.org/wiki/Sierpinski_triangle for more information and possible algorithms.

Thursday, August 25, 2011 9:01 PM

All replies

• Im worthless at this... we done this stuff at school... the triangle one looks like super pain in the ass xD.
I love game design and game programing.
Thursday, August 25, 2011 11:45 PM
• Im worthless at this... we done this stuff at school... the triangle one looks like super pain in the ass xD.
I love game design and game programing.
I'm sure you can do the 'Easy Challenge' - a nested FOR loop will do the trick ...
Friday, August 26, 2011 12:24 AM
• Are you British ?
I love game design and game programing.
Friday, August 26, 2011 10:24 AM
• Are you British ?
I love game design and game programing.
Yes. Is it that obvious?
Friday, August 26, 2011 10:46 AM
• Yes from your time of making this thread i realized it has to be Britain because your -1 GMT from my country and those near mine.
I love game design and game programing.
Friday, August 26, 2011 11:06 AM
• Yes from your time of making this thread i realized it has to be Britain because your -1 GMT from my country and those near mine.
I love game design and game programing.
I also posted it a bit early - about 10pm local time.
Friday, August 26, 2011 11:25 AM

I wrote MRZ834 for shooting.

You must press right or left key to face the target.

(not automatic facing)

Up ; move forward(to target)   Down ;move backward

space:shooting

(If Timer.start(500) does't work, change it to Time.interval=500.)

Monday, August 29, 2011 9:13 AM
• Nice that you have added a target to shoot at as well!

What's with the timer.start(500) ? It is not accepted in my copy of SmallBasic?

Monday, August 29, 2011 8:25 PM
• Sorry,  Timer.start(500) command is a smallbasicfun extension.

I changed the  code  to Time.interval=500.

And   the content was reviewed a little.

Tuesday, August 30, 2011 12:09 AM
• Dude you need to get origin it's easy. I was using Game Maker for 2 years and still planing to finish my huge project and i know so do width and height / 2 to get origin to middle.
I love game design and game programing.
Tuesday, August 30, 2011 8:24 PM
• Week 9 - Advanced Challenge

Here is (my own!) submission - Import QRS854

This program uses the Chaos Game Algorithm as described in the Wikipedia article linked at the top of this page. It's amazing what can be done with random numbers! Obviously there are other algorithms that could be used - any takers?

One thing that I do not understand is why the program runs so much faster when viewed in a browser compared to running it within SmallBasic. Does anyone else see this speed difference? Link

In the source code I have included comments with a couple of possible extensions that some of you may like to try.

Wednesday, August 31, 2011 9:49 PM
• I wrote Sierpinski Triangle RBB339.(using animation)

I think the result (Appearance) is Sierpinski Triangle .

(Maybe not theoretical)

you'd better take step number <= 7.

When over 7, it terribly takes time.

Sunday, September 04, 2011 11:50 PM
• I wrote Sierpinski Triangle RBB339.(using animation)

I think the result (Appearance) is Sierpinski Triangle .

(Maybe not theoretical)

you'd better take step number <= 7.

When over 7, it terribly takes time.

VERY NICE! Well done!
Monday, September 05, 2011 12:02 AM
• Could you give some hints on the fractal cuz I've been thinking where should I start and I don't know what should i do first....

thanks

Monday, September 05, 2011 7:23 PM
• Could you give some hints on the fractal cuz I've been thinking where should I start and I don't know what should i do first....

thanks

Taken from Wikipedia:

1. Take 3 points in a plane to form a triangle, you need not draw it.
2. Randomly select any point inside (or outside) the triangle and consider that your current position.
3. Randomly select any one of the 3 vertex points.
4. Move half the distance from your current position to the selected vertex. (Use the Midpoint formula)
5. Plot the current position.
6. Repeat from step 3.

This is the method that I used to write QRS854

• Edited by Monday, September 05, 2011 7:35 PM
Monday, September 05, 2011 7:34 PM
• Firstly, I wrote this figure.  Please refer.

Tuesday, September 06, 2011 1:41 AM