Local Variables (New Features)

by M Santos, Tuesday, October 30, 2012, 21:10 (2450 days ago) @ Jim

Hi Jim
I´m doing a project with my year 7 class. Each student makes a car or a house and then I put it in a subroutine and add some movement.
See the example below.
We have to use a different variable x x1 x2 x3 .... for each car, or else the program will consider as a unique variable.

graphsize 900,500

for p = 1 to 100000 step 1
call ritacar(p)
call sidneycar(p)
next p

subroutine ritacar(p)
if p=1 then x=400
if x>1000 then x = 0
color yellow
rect 910-x,270+y,60,20
color yellow
rect 930-x,230+y,70,60
color black
font "Arial Black",12,50
Text 935-x,230+y,"School"
color darkcyan
rect 935-x,250+y,60,20
color black
circle 925-x,290+y,10
color black
circle 990-x,290+y,10
end subroutine

subroutine sidneycar(p)
if p=1 then x1=0
if x1>1200 then x1 = 0
color darkblue
rect 910-x1,270+y,60,20
color darkblue
rect 930-x1,260+y,40,20
color black
circle 925-x1,290+y,10
color black
circle 955-x1,290+y,10
end subroutine

Complete thread:

 RSS Feed of thread

powered by my little forum