New users fun with Basic

Post Reply
Dalede
Posts: 131
Joined: Fri Dec 28, 2012 4:00 pm
Location: Grass Valley, CA, USA
Contact:

New users fun with Basic

Post by Dalede »

If you are not really familiar with basic then the best way to learn is to study some of the sample programs that came with Smart Basic and then modify them to get an idea of how things work. Let's start with the program called winter.txt (old timers may not have this sample but if you do a restore and it will appear). Run the program and note that it does a really nice job of showing how images can be used in a program and it fun to watch. But what if it were a bit colder! We have the control since we can add to the program.

Edit the program and notice the nice clean code. Near the bottom you can see a loop called loop and it contains two small sections. One called move flakes and one called draw tree and flakes. We are going to tweak them both.

The move flakes is a for loop and ends in next i, the line above says "end if" Click just above this and open a new line. Add the text: snow=snow+.1
It should be just above the end if.

The next section starts with graphics lock and ends with graphics unlock. Just above that is the words next i. Click on the end of this line and hit return to open a new line and add the following three lines.

For i=0 to snow
draw line 0, maxy-i to maxx, maxy-i
next i

this should be just above the words graphic unlock.

Now run the program and watch for a while. It is clearly a bit colder now!

Dale
Last edited by Dalede on Wed Mar 20, 2013 8:07 pm, edited 1 time in total.

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: New users fun with Basic

Post by Mr. Kibernetik »

Dalede wrote: For i=0 to snow
draw line 0, maxy-i to maxx, maxy-1
next i
Nice idea!

I can suppose here you wanted draw line 0, maxy-i to maxx, maxy-i

My suggestion to modify your code:
instead of your "For i=0 to snow" cycle to use this one:
for i=0 to snow step 0.2
draw to 0,maxy
for x=0 to maxx step 5
draw line to x, maxy-i*300/maxx*(sin(x*maxx/5000) + 3)
next x
next i

Dalede
Posts: 131
Joined: Fri Dec 28, 2012 4:00 pm
Location: Grass Valley, CA, USA
Contact:

Re: New users fun with Basic

Post by Dalede »

Yes, I meant i not 1. Nice catch. That is what I get for typing it in.

Ah I see you have something for the more advanced student. A little to wavy for me :)

Dale

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: New users fun with Basic

Post by Mr. Kibernetik »

Dalede wrote:A little to wavy for me :)
Well, in Russia there is as much snow... :)

Post Reply