The Small (And Big) Tricks to BASIC programming


Even though we learn the basics, there must be some little tricks to BASIC:

  • Using The “Majalo” Command To Switch Players

In a player game, you might want to switch between players. A simple 2-person game between player “0” and player “1”  probably is hard to program, but “Majalo”, or the remainder of the quotient, is here to help! You can freely copy this line to use Majalo to switch/alternate between two players:

(a+1)%2

The % sign should symbol the Majalo command. Even though it might seem confusing at first, This should clear it up:

a+1

That’s simple. a (or whatever variable you have)and add 1. If you are on player 0, a=0, if you are on player 1, a=1. Then you add 1, thus player 1 and so-called player 2 have the turn.

(<answer>)%2

Now, if you see, if player “1” is the turn, 1%2=1. If player “2” has the turn, 2%2=0, thus actually player 0 has their turn

  • Skipping a line (0r 10)

Now when I write loong basic programs and want to add to them, I find it depressing that you cannot add .5 of a direction. MASICA turns up a Syntax Error here:

1 print “Hello World”

1.5 print “What’s your view?”

2 input g

3 if g!=”No Idea” then print “Good Job!”

4 endif (optional)

5 print “WHATT!”

Thus, I seperate each line by 10 so I can add 10 lines before mega-shifting. (btw, The erase followed by a line command erases a line from the list).

  • Creating Graphical Arts

Normally BASIC cannot do graphical stuff, but this simple program can create a simple graphical maze:

10 b=rnd(2)

20 if b==0 then print “/”

30 if b==1 then print”\”

40 goto 10

Of course, you can modify #10 to make the rnd more wholesome, like changing the number 2 to 10, and create new symbols.

Wish ya’ a happy programming- And yes, there is 4-6 inches of snow expected here tomorrow. WHAT?!?!?!

Advertisements

The Debate Form

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s