tag:blogger.com,1999:blog-75993585000884158332024-03-12T21:58:52.965-07:00Basic Bits - Copy paste & runThis is a set of small programs in Basic-256, related to various topics.
Just copy,paste and run.
Note : Sometimes programs do not run in recent BASIC 256 versions.Unknownnoreply@blogger.comBlogger126125tag:blogger.com,1999:blog-7599358500088415833.post-39403358897079423802016-04-16T07:42:00.003-07:002016-04-16T07:52:46.231-07:00Play station Joystick test<div dir="ltr" style="text-align: left;" trbidi="on">
#Basic code<br />
clg<br />
graphsize 500,500<br />
font "arial",10,100<br />
openserial 1, "COM3"<br />
x=250<br />
y=250<br />
dx=0<br />
dy=0<br />
for a = 1 to 90000<br />
n=asc (read(1))<br />
if int (n/10)=1 then dx=-1<br />
if int (n/10)=2 then dx=0<br />
if int (n/10)=3 then dx=1<br />
if int (n/10)=4 then dy=-1<br />
if int (n/10)=5 then dy=0<br />
if int (n/10)=6 then dy=1<br />
x=x-dx<br />
y=y+dy<br />
circle x, y,2<br />
next a<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-zTQQNimfwA8/VxJQ_t9bi-I/AAAAAAAAAms/jB1OiT6QVeQIqMmhda89mwQ0kDJkSMHZQCLcB/s1600/ps2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="185" src="https://3.bp.blogspot.com/-zTQQNimfwA8/VxJQ_t9bi-I/AAAAAAAAAms/jB1OiT6QVeQIqMmhda89mwQ0kDJkSMHZQCLcB/s400/ps2.png" width="400" /></a></div>
<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-3751buIsht8/VxJRbGBxQ-I/AAAAAAAAAmw/bpLKlHY1mGYvcClSQuvZaxYKv4Cxv1huACLcB/s1600/ps2%2Btest.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="318" src="https://3.bp.blogspot.com/-3751buIsht8/VxJRbGBxQ-I/AAAAAAAAAmw/bpLKlHY1mGYvcClSQuvZaxYKv4Cxv1huACLcB/s320/ps2%2Btest.png" width="320" /></a></div>
<br />
<br />
// Arduino code <br />
int x = 0;<br />
int y = 0;<br />
int F = 0; <br />
void setup()<br />
{ Serial.begin(9600);<br />
}<br />
void loop()<br />
{<br />
x = map(analogRead(1),0,1023,15,35);<br />
y = map(analogRead(2),0,1023,45,65);<br />
F = map(analogRead(0),0,1023,78,88); <br />
Serial.write(x);<br />
delay(10);<br />
Serial.write(y);<br />
delay(10);<br />
Serial.write(F);<br />
delay(10);<br />
}</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7599358500088415833.post-38431756757564500982016-04-14T03:23:00.003-07:002016-04-14T03:26:20.589-07:00Parametric Spirograph<div dir="ltr" style="text-align: left;" trbidi="on">
<a href="https://1.bp.blogspot.com/-I6cOH_5W7wg/Vw9vqHNrgWI/AAAAAAAAAmM/SDD1rxEM19ELpmnHKhTr5qH0yEZ17uAoACLcB/s1600/Spirograph.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="https://1.bp.blogspot.com/-I6cOH_5W7wg/Vw9vqHNrgWI/AAAAAAAAAmM/SDD1rxEM19ELpmnHKhTr5qH0yEZ17uAoACLcB/s1600/Spirograph.png" /></a><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">r=90</span><br />
<span style="font-family: Courier New, Courier, monospace;">centerx=150</span><br />
<span style="font-family: Courier New, Courier, monospace;">centery=150</span><br />
<span style="font-family: Courier New, Courier, monospace;">rm=30</span><br />
<span style="font-family: Courier New, Courier, monospace;">for n = 1 to 6</span><br />
<span style="font-family: Courier New, Courier, monospace;">color rgb(int (rand*3)*127, int(rand*3)*127, int(rand*3)*127)</span><br />
<span style="font-family: Courier New, Courier, monospace;">for t = 0 to 6.28 step .002</span><br />
<span style="font-family: Courier New, Courier, monospace;">x=r*sin(t)+centerx</span><br />
<span style="font-family: Courier New, Courier, monospace;">y=r*cos(t)+centery</span><br />
<span style="font-family: Courier New, Courier, monospace;">xm=rm*sin(-t*3*n)+x</span><br />
<span style="font-family: Courier New, Courier, monospace;">ym=rm*cos(-t*3*n)+y</span><br />
<span style="font-family: Courier New, Courier, monospace;">circle xm,ym,1</span><br />
<span style="font-family: Courier New, Courier, monospace;">next t</span><br />
<span style="font-family: Courier New, Courier, monospace;">next n</span></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7599358500088415833.post-59644109220751795792016-04-09T10:15:00.000-07:002016-04-15T04:10:08.251-07:00Graphing a sensor using Arduino<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<span style="font-family: "courier new" , "courier" , monospace;">#Basic code</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">graphsize 900,300</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">font "arial",10,100</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">openserial 1, "COM4"</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">for window = 1 to 300</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">clg</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">for l = 25 to 325 step 25</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">line 30,l,900,l</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">text 0,l-5,5.5-int(l)/50+"V"</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">next l</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">for x = 1 to 900</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">pause .01</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">n=asc (read(1))</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">print n</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">circle x,277-2*n,2</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">next x</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">next window</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-QEFYGmgwkhA/VwlbUndLrII/AAAAAAAAAl4/1mtRanHdKVsKUouTkx8fX3OREK75_FAKQ/s1600/fritz.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="202" src="https://2.bp.blogspot.com/-QEFYGmgwkhA/VwlbUndLrII/AAAAAAAAAl4/1mtRanHdKVsKUouTkx8fX3OREK75_FAKQ/s320/fritz.png" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-hWM_68jbwQA/Vwk4ZfF0VoI/AAAAAAAAAlk/ce4lUwukxJAeeaj3lrS2nty_c4kpbMOQg/s1600/IMG_20160409_180641.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="180" src="https://4.bp.blogspot.com/-hWM_68jbwQA/Vwk4ZfF0VoI/AAAAAAAAAlk/ce4lUwukxJAeeaj3lrS2nty_c4kpbMOQg/s320/IMG_20160409_180641.jpg" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-7l6hNK-wSo8/VxDLdrtJFwI/AAAAAAAAAmc/zsoE0Orf7LsPcRD4zNoZdcnYIBTH8T1xACLcB/s1600/potenc.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="142" src="https://4.bp.blogspot.com/-7l6hNK-wSo8/VxDLdrtJFwI/AAAAAAAAAmc/zsoE0Orf7LsPcRD4zNoZdcnYIBTH8T1xACLcB/s400/potenc.png" width="400" /></a></div>
<br />
<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;">// Arduino code</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> int L = 0;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> int S = 0; </span><br />
<span style="font-family: "courier new" , "courier" , monospace;">void setup()</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">{ Serial.begin(9600); }</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">void loop()</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">{</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> L = analogRead(2);</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> S = map(L ,0,1023,0,127);</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> //Serial.println(L); </span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> Serial.write(S); </span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> delay(50);</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">}</span></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7599358500088415833.post-45234542158099341952016-04-08T07:58:00.001-07:002016-04-08T07:59:10.352-07:00Hello World<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: "courier new" , "courier" , monospace;"># Creates a file and writes hellow world</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"># The file is in the same folder as the basic application</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"># Use notepad or word to open</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">open "blackboard.txt"</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">write "Hello world"</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-4apbGkb9aQM/VwfHDTKf_dI/AAAAAAAAAlQ/aU6izSiHaDMyDq4RyJaOkg3J29StF_mlA/s1600/Hello%2Bworld.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://1.bp.blogspot.com/-4apbGkb9aQM/VwfHDTKf_dI/AAAAAAAAAlQ/aU6izSiHaDMyDq4RyJaOkg3J29StF_mlA/s1600/Hello%2Bworld.png" /></a></div>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7599358500088415833.post-9544560729817766362015-02-23T14:25:00.004-08:002015-02-23T14:25:42.736-08:00Pythagoras Game<div dir="ltr" style="text-align: left;" trbidi="on">
graphsize 600,400<br />
color black<br />
rect 0,0,600,400<br />
color white<br />
x1=int(rand*600)<br />
y1=int(rand*400)<br />
circle x1,y1,3<br />
x2=int(rand*600)<br />
y2=int(rand*400)<br />
circle x2,y2,3<br />
# Vertical and Horizontal distance<br />
h=x1-x2<br />
v=y1-y2<br />
# Pythagoras formula<br />
dist=sqrt(v^2+h^2)<br />
Print "The black rectangle is 600 by 400"<br />
input "What is the distance between the points",a<br />
font "arial" ,30,30<br />
<br />
text 150,200,"Distance="+int(dist)</div>
Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-7599358500088415833.post-90087906331682558812015-02-15T00:35:00.000-08:002015-02-17T02:14:54.221-08:00Pac Man<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-Xot9tpzOn8E/VOBZVALVBHI/AAAAAAAAAiM/OI0v6NsmLFw/s1600/PacMan.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="http://3.bp.blogspot.com/-Xot9tpzOn8E/VOBZVALVBHI/AAAAAAAAAiM/OI0v6NsmLFw/s1600/PacMan.png" height="214" width="320" /></a></div>
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"><br />
</span> <span style="font-family: Courier New, Courier, monospace;">levels=1</span><br />
<span style="font-family: Courier New, Courier, monospace;">fastgraphics</span><br />
<span style="font-family: Courier New, Courier, monospace;">graphsize 600,600</span><br />
<span style="font-family: Courier New, Courier, monospace;">clg</span><br />
<span style="font-family: Courier New, Courier, monospace;">dim board$ (16,levels)</span><br />
<span style="font-family: Courier New, Courier, monospace;">dim area$ (16,30)</span><br />
<span style="font-family: Courier New, Courier, monospace;">dim monstersname$(4)</span><br />
<span style="font-family: Courier New, Courier, monospace;">dim monsterx(4)</span><br />
<span style="font-family: Courier New, Courier, monospace;">dim monstery(4)</span><br />
<span style="font-family: Courier New, Courier, monospace;">dim monsterxspeed(4)</span><br />
<span style="font-family: Courier New, Courier, monospace;">dim monsteryspeed(4)</span><br />
<span style="font-family: Courier New, Courier, monospace;">board$ [0,0]= "HHHHHHHHHHHHHHHHHHHHHHH "</span><br />
<span style="font-family: Courier New, Courier, monospace;">board$ [1,0]= "H**********H**********H Score "</span><br />
<span style="font-family: Courier New, Courier, monospace;">board$ [2,0]= "H@HHH*HHHH*H*HHHH*HHH@H "</span><br />
<span style="font-family: Courier New, Courier, monospace;">board$ [3,0]= "H*********************H "</span><br />
<span style="font-family: Courier New, Courier, monospace;">board$ [4,0]= "H*HHH*H*HHH HHH*H*HHH*H @ 5P "</span><br />
<span style="font-family: Courier New, Courier, monospace;">board$ [5,0]= "H*****H*********H*****H "</span><br />
<span style="font-family: Courier New, Courier, monospace;">board$ [6,0]= "HHHHH*H*HHHHHHH*H*HHHHH * 1p "</span><br />
<span style="font-family: Courier New, Courier, monospace;">board$ [7,0]= "HHHHH*H H*HHHHH "</span><br />
<span style="font-family: Courier New, Courier, monospace;">board$ [8,0]= "HHHHH*H HHH HHH H*HHHHH "</span><br />
<span style="font-family: Courier New, Courier, monospace;">board$ [9,0]= " H H Lifes "</span><br />
<span style="font-family: Courier New, Courier, monospace;">board$ [10,0]="H*HHH*H HHHHHHH H*HHH*H "</span><br />
<span style="font-family: Courier New, Courier, monospace;">board$ [11,0]="H@HHH*H H*HHH@H "</span><br />
<span style="font-family: Courier New, Courier, monospace;">board$ [12,0]="H*HHH*H*HHH*HHH*H*HHH*H "</span><br />
<span style="font-family: Courier New, Courier, monospace;">board$ [13,0]="H*HHH*H*HHH*HHH*H*HHH*H "</span><br />
<span style="font-family: Courier New, Courier, monospace;">board$ [14,0]="H*********************H "</span><br />
<span style="font-family: Courier New, Courier, monospace;">board$ [15,0]="HHHHHHHHHHHHHHHHHHHHHHH "</span><br />
<span style="font-family: Courier New, Courier, monospace;">font "courier" ,25,200</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"># To put the board in a 2D array easier to handle</span><br />
<span style="font-family: Courier New, Courier, monospace;">for row = 0 to 15</span><br />
<span style="font-family: Courier New, Courier, monospace;"> for collum = 0 to 29</span><br />
<span style="font-family: Courier New, Courier, monospace;"> area$ [row,collum]= mid( board$ [row,0],collum+1,1)</span><br />
<span style="font-family: Courier New, Courier, monospace;"> next collum</span><br />
<span style="font-family: Courier New, Courier, monospace;">next row</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"># Main loop</span><br />
<span style="font-family: Courier New, Courier, monospace;">for life = 3 to 0 step- 1</span><br />
<span style="font-family: Courier New, Courier, monospace;"># Drawing the board</span><br />
<span style="font-family: Courier New, Courier, monospace;">color black</span><br />
<span style="font-family: Courier New, Courier, monospace;">rect 0,0,600,405</span><br />
<span style="font-family: Courier New, Courier, monospace;">for y = 0 to 15</span><br />
<span style="font-family: Courier New, Courier, monospace;"> for x = 0 to 29</span><br />
<span style="font-family: Courier New, Courier, monospace;"> if area$[y,x]= "H" then color white</span><br />
<span style="font-family: Courier New, Courier, monospace;"> if area$[y,x]= "*" then color Yellow</span><br />
<span style="font-family: Courier New, Courier, monospace;"> if area$[y,x]= "@" then color red</span><br />
<span style="font-family: Courier New, Courier, monospace;"> text x*20,y*25,area$[y,x]</span><br />
<span style="font-family: Courier New, Courier, monospace;"> next x</span><br />
<span style="font-family: Courier New, Courier, monospace;">next y</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">if life = 0 then</span><br />
<span style="font-family: Courier New, Courier, monospace;">color green</span><br />
<span style="font-family: Courier New, Courier, monospace;">font "Aril" ,50,100</span><br />
<span style="font-family: Courier New, Courier, monospace;">Text 50,50,"GAME OVER"</span><br />
<span style="font-family: Courier New, Courier, monospace;">refresh</span><br />
<span style="font-family: Courier New, Courier, monospace;">end</span><br />
<span style="font-family: Courier New, Courier, monospace;">end if</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span><span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"># initial variables for packman</span><br />
<span style="font-family: Courier New, Courier, monospace;">xspeed = 1</span><br />
<span style="font-family: Courier New, Courier, monospace;">yspeed = 0</span><br />
<span style="font-family: Courier New, Courier, monospace;">xpac = 220</span><br />
<span style="font-family: Courier New, Courier, monospace;">ypac = 125</span><br />
<span style="font-family: Courier New, Courier, monospace;">mouth=0</span><br />
<span style="font-family: Courier New, Courier, monospace;">Score = 0</span><br />
<span style="font-family: Courier New, Courier, monospace;">dead = false</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"># initial positions for monsters</span><br />
<span style="font-family: Courier New, Courier, monospace;">monstersname$[0]="Blue"</span><br />
<span style="font-family: Courier New, Courier, monospace;">monsterx[0]=190</span><br />
<span style="font-family: Courier New, Courier, monospace;">monstery[0]=240</span><br />
<span style="font-family: Courier New, Courier, monospace;">monsterxspeed[0]=1</span><br />
<span style="font-family: Courier New, Courier, monospace;">monsteryspeed[0]=0</span><br />
<span style="font-family: Courier New, Courier, monospace;">monstersname$[1]="Yellow"</span><br />
<span style="font-family: Courier New, Courier, monospace;">monsterx[1]=210</span><br />
<span style="font-family: Courier New, Courier, monospace;">monstery[1]=240</span><br />
<span style="font-family: Courier New, Courier, monospace;">monsterxspeed[1]=1</span><br />
<span style="font-family: Courier New, Courier, monospace;">monsteryspeed[1]=0</span><br />
<span style="font-family: Courier New, Courier, monospace;">monstersname$[2]="Orange"</span><br />
<span style="font-family: Courier New, Courier, monospace;">monsterx[2]=190</span><br />
<span style="font-family: Courier New, Courier, monospace;">monstery[2]=240</span><br />
<span style="font-family: Courier New, Courier, monospace;">monsterxspeed[2]=-1</span><br />
<span style="font-family: Courier New, Courier, monospace;">monsteryspeed[2]=0</span><br />
<span style="font-family: Courier New, Courier, monospace;">monstersname$[3]="Purple"</span><br />
<span style="font-family: Courier New, Courier, monospace;">monsterx[3]=210</span><br />
<span style="font-family: Courier New, Courier, monospace;">monstery[3]=240</span><br />
<span style="font-family: Courier New, Courier, monospace;">monsterxspeed[3]=-1</span><br />
<span style="font-family: Courier New, Courier, monospace;">monsteryspeed[3]=0</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"># Action loop</span><br />
<span style="font-family: Courier New, Courier, monospace;">do </span><br />
<span style="font-family: Courier New, Courier, monospace;"> gosub packman</span><br />
<span style="font-family: Courier New, Courier, monospace;"> gosub monsters</span><br />
<span style="font-family: Courier New, Courier, monospace;">refresh</span><br />
<span style="font-family: Courier New, Courier, monospace;">pause .01</span><br />
<span style="font-family: Courier New, Courier, monospace;">if Score = 139 then</span><br />
<span style="font-family: Courier New, Courier, monospace;">color green</span><br />
<span style="font-family: Courier New, Courier, monospace;">font "Aril" ,50,100</span><br />
<span style="font-family: Courier New, Courier, monospace;">Text 50,50,"You won"</span><br />
<span style="font-family: Courier New, Courier, monospace;">refresh</span><br />
<span style="font-family: Courier New, Courier, monospace;">end</span><br />
<span style="font-family: Courier New, Courier, monospace;">end if</span><br />
<span style="font-family: Courier New, Courier, monospace;">until dead = true</span><br />
<span style="font-family: Courier New, Courier, monospace;">next life</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">monsters:</span><br />
<span style="font-family: Courier New, Courier, monospace;">for n = 0 to 3</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"># Erases monster for next frame</span><br />
<span style="font-family: Courier New, Courier, monospace;">color black</span><br />
<span style="font-family: Courier New, Courier, monospace;">rect monsterx[n]-10,monstery[n]-10,21,21</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"># Changing monster direction </span><br />
<span style="font-family: Courier New, Courier, monospace;">if (monsterx[n]+10)%20 =0 and (monstery[n]+10)%25=0 then</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">xcell=int((monsterx[n])/20)</span><br />
<span style="font-family: Courier New, Courier, monospace;">ycell=int(monstery[n]/25)</span><br />
<span style="font-family: Courier New, Courier, monospace;">self$ = area$[ycell,xcell]</span><br />
<span style="font-family: Courier New, Courier, monospace;">lef$ = area$[ycell,xcell-1]</span><br />
<span style="font-family: Courier New, Courier, monospace;">righ$ = area$[ycell,xcell+1]</span><br />
<span style="font-family: Courier New, Courier, monospace;">up$ = area$[ycell-1,xcell]</span><br />
<span style="font-family: Courier New, Courier, monospace;">down$ = area$[ycell+1,xcell]</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">flag=false</span><br />
<span style="font-family: Courier New, Courier, monospace;"># when the monster is going right</span><br />
<span style="font-family: Courier New, Courier, monospace;">if monsterxspeed[n]=1 then</span><br />
<span style="font-family: Courier New, Courier, monospace;">if up$<>"H" and int(rand*2)>0 and flag = false then</span><br />
<span style="font-family: Courier New, Courier, monospace;">monsteryspeed[n]=-1</span><br />
<span style="font-family: Courier New, Courier, monospace;">monsterxspeed[n]=0</span><br />
<span style="font-family: Courier New, Courier, monospace;">flag=true</span><br />
<span style="font-family: Courier New, Courier, monospace;">end if</span><br />
<span style="font-family: Courier New, Courier, monospace;">if down$<>"H" and flag = false then</span><br />
<span style="font-family: Courier New, Courier, monospace;">monsteryspeed[n]=1</span><br />
<span style="font-family: Courier New, Courier, monospace;">monsterxspeed[n]=0</span><br />
<span style="font-family: Courier New, Courier, monospace;">flag=true</span><br />
<span style="font-family: Courier New, Courier, monospace;">end if</span><br />
<span style="font-family: Courier New, Courier, monospace;">if righ$="H" and flag = false then</span><br />
<span style="font-family: Courier New, Courier, monospace;">monsteryspeed[n]=0</span><br />
<span style="font-family: Courier New, Courier, monospace;">monsterxspeed[n]=-1</span><br />
<span style="font-family: Courier New, Courier, monospace;">flag=true</span><br />
<span style="font-family: Courier New, Courier, monospace;">end if</span><br />
<span style="font-family: Courier New, Courier, monospace;">if lef$= "*" then color Yellow</span><br />
<span style="font-family: Courier New, Courier, monospace;">if lef$= "@" then color red</span><br />
<span style="font-family: Courier New, Courier, monospace;">if lef$= "*" or lef$= "@" then text (xcell-1)*20,ycell*25,lef$</span><br />
<span style="font-family: Courier New, Courier, monospace;">end if</span><br />
<span style="font-family: Courier New, Courier, monospace;"># when the monster is going left</span><br />
<span style="font-family: Courier New, Courier, monospace;">if monsterxspeed[n]=-1 then</span><br />
<span style="font-family: Courier New, Courier, monospace;">if up$<>"H" and int(rand*2)>0 and flag = false then</span><br />
<span style="font-family: Courier New, Courier, monospace;">monsteryspeed[n]=-1</span><br />
<span style="font-family: Courier New, Courier, monospace;">monsterxspeed[n]=0</span><br />
<span style="font-family: Courier New, Courier, monospace;">flag=true</span><br />
<span style="font-family: Courier New, Courier, monospace;">end if</span><br />
<span style="font-family: Courier New, Courier, monospace;">if down$<>"H" and flag = false then</span><br />
<span style="font-family: Courier New, Courier, monospace;">monsteryspeed[n]=1</span><br />
<span style="font-family: Courier New, Courier, monospace;">monsterxspeed[n]=0</span><br />
<span style="font-family: Courier New, Courier, monospace;">flag=true</span><br />
<span style="font-family: Courier New, Courier, monospace;">end if</span><br />
<span style="font-family: Courier New, Courier, monospace;">if lef$="H" and flag = false then</span><br />
<span style="font-family: Courier New, Courier, monospace;">monsteryspeed[n]=0</span><br />
<span style="font-family: Courier New, Courier, monospace;">monsterxspeed[n]=1</span><br />
<span style="font-family: Courier New, Courier, monospace;">flag=true</span><br />
<span style="font-family: Courier New, Courier, monospace;">end if</span><br />
<span style="font-family: Courier New, Courier, monospace;">if righ$= "*" then color Yellow</span><br />
<span style="font-family: Courier New, Courier, monospace;">if righ$= "@" then color red</span><br />
<span style="font-family: Courier New, Courier, monospace;">if righ$= "*" or righ$= "@" then text (xcell+1)*20,ycell*25,righ$</span><br />
<span style="font-family: Courier New, Courier, monospace;">end if</span><br />
<span style="font-family: Courier New, Courier, monospace;"># when the monster is going up</span><br />
<span style="font-family: Courier New, Courier, monospace;">if monsteryspeed[n]=-1 then</span><br />
<span style="font-family: Courier New, Courier, monospace;">if lef$<>"H" and int(rand*2)>0 and flag = false then</span><br />
<span style="font-family: Courier New, Courier, monospace;">monsteryspeed[n]=0</span><br />
<span style="font-family: Courier New, Courier, monospace;">monsterxspeed[n]=-1</span><br />
<span style="font-family: Courier New, Courier, monospace;">flag = true</span><br />
<span style="font-family: Courier New, Courier, monospace;">end if</span><br />
<span style="font-family: Courier New, Courier, monospace;">if righ$<>"H" and flag = false then</span><br />
<span style="font-family: Courier New, Courier, monospace;">monsteryspeed[n]=0</span><br />
<span style="font-family: Courier New, Courier, monospace;">monsterxspeed[n]=1</span><br />
<span style="font-family: Courier New, Courier, monospace;">flag = true</span><br />
<span style="font-family: Courier New, Courier, monospace;">end if</span><br />
<span style="font-family: Courier New, Courier, monospace;">if up$="H" and flag = false then</span><br />
<span style="font-family: Courier New, Courier, monospace;">monsteryspeed[n]=1</span><br />
<span style="font-family: Courier New, Courier, monospace;">monsterxspeed[n]=0</span><br />
<span style="font-family: Courier New, Courier, monospace;">flag=true</span><br />
<span style="font-family: Courier New, Courier, monospace;">end if</span><br />
<span style="font-family: Courier New, Courier, monospace;">if down$= "*" then color Yellow</span><br />
<span style="font-family: Courier New, Courier, monospace;">if down$= "@" then color red</span><br />
<span style="font-family: Courier New, Courier, monospace;">if down$= "*" or down$= "@" then text xcell*20,(ycell+1)*25,down$</span><br />
<span style="font-family: Courier New, Courier, monospace;">end if</span><br />
<span style="font-family: Courier New, Courier, monospace;"># when the monster is going down</span><br />
<span style="font-family: Courier New, Courier, monospace;">if monsteryspeed[n]=1 then</span><br />
<span style="font-family: Courier New, Courier, monospace;">if lef$<>"H" and int(rand*2)>0 and flag = false then</span><br />
<span style="font-family: Courier New, Courier, monospace;">monsteryspeed[n]=0</span><br />
<span style="font-family: Courier New, Courier, monospace;">monsterxspeed[n]=-1</span><br />
<span style="font-family: Courier New, Courier, monospace;">flag = true</span><br />
<span style="font-family: Courier New, Courier, monospace;">end if</span><br />
<span style="font-family: Courier New, Courier, monospace;">if righ$<>"H" and flag = false then</span><br />
<span style="font-family: Courier New, Courier, monospace;">monsteryspeed[n]=0</span><br />
<span style="font-family: Courier New, Courier, monospace;">monsterxspeed[n]=1</span><br />
<span style="font-family: Courier New, Courier, monospace;">flag = true</span><br />
<span style="font-family: Courier New, Courier, monospace;">end if</span><br />
<span style="font-family: Courier New, Courier, monospace;">if down$="H" and flag = false then</span><br />
<span style="font-family: Courier New, Courier, monospace;">monsteryspeed[n]=-1</span><br />
<span style="font-family: Courier New, Courier, monospace;">monsterxspeed[n]=0</span><br />
<span style="font-family: Courier New, Courier, monospace;">flag = true</span><br />
<span style="font-family: Courier New, Courier, monospace;">end if</span><br />
<span style="font-family: Courier New, Courier, monospace;">if up$= "*" then color Yellow</span><br />
<span style="font-family: Courier New, Courier, monospace;">if up$= "@" then color red</span><br />
<span style="font-family: Courier New, Courier, monospace;">if up$= "*" or up$= "@" then text xcell*20,(ycell-1)*25,up$</span><br />
<span style="font-family: Courier New, Courier, monospace;">end if</span><br />
<span style="font-family: Courier New, Courier, monospace;">end if</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"># Shift from left to right of the board </span><br />
<span style="font-family: Courier New, Courier, monospace;">IF monsterx[n] = 15 THEN monsterx[n] = 435</span><br />
<span style="font-family: Courier New, Courier, monospace;">IF monsterx[n] = 440 THEN monsterx[n] = 15</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">monsterx[n]=monsterx[n]+monsterxspeed[n]</span><br />
<span style="font-family: Courier New, Courier, monospace;">monstery[n]=monstery[n]+monsteryspeed[n]</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"># Drawing the monsters</span><br />
<span style="font-family: Courier New, Courier, monospace;">if n = 0 then color Blue</span><br />
<span style="font-family: Courier New, Courier, monospace;">if n = 1 then color Orange</span><br />
<span style="font-family: Courier New, Courier, monospace;">if n = 2 then color Yellow</span><br />
<span style="font-family: Courier New, Courier, monospace;">if n = 3 then color Purple</span><br />
<span style="font-family: Courier New, Courier, monospace;">Circle monsterx[n],monstery[n],10</span><br />
<span style="font-family: Courier New, Courier, monospace;">rect monsterx[n]-10,monstery[n],21,11</span><br />
<span style="font-family: Courier New, Courier, monospace;"># Monsters eyes and mouth</span><br />
<span style="font-family: Courier New, Courier, monospace;">color white</span><br />
<span style="font-family: Courier New, Courier, monospace;">Circle monsterx[n]-3,monstery[n]-4,4</span><br />
<span style="font-family: Courier New, Courier, monospace;">Circle monsterx[n]+3,monstery[n]-4,4</span><br />
<span style="font-family: Courier New, Courier, monospace;">color black</span><br />
<span style="font-family: Courier New, Courier, monospace;">Circle monsterx[n]-3+monsterxspeed[n]*2,monstery[n]+monsteryspeed[n]*2-4,2</span><br />
<span style="font-family: Courier New, Courier, monospace;">Circle monsterx[n]+3+monsterxspeed[n]*2,monstery[n]-4+monsteryspeed[n]*2,2</span><br />
<span style="font-family: Courier New, Courier, monospace;">rect monsterx[n]-4,monstery[n]+4,8,3</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"># Pac dies</span><br />
<span style="font-family: Courier New, Courier, monospace;">if abs(monsterx[n] - (xpac+10))<2 and abs(monstery[n]-(ypac+15))<2 then </span><br />
<span style="font-family: Courier New, Courier, monospace;">dead = true</span><br />
<span style="font-family: Courier New, Courier, monospace;">sound 1000,1000</span><br />
<span style="font-family: Courier New, Courier, monospace;">end if</span><br />
<span style="font-family: Courier New, Courier, monospace;">next n</span><br />
<br />
<span style="font-family: Courier New, Courier, monospace;">return</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">packman:</span><br />
<span style="font-family: Courier New, Courier, monospace;"># Erases pacman for next frame</span><br />
<span style="font-family: Courier New, Courier, monospace;">color black</span><br />
<span style="font-family: Courier New, Courier, monospace;">rect xpac,ypac,20,28</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"># Identifies the cells around pacman</span><br />
<span style="font-family: Courier New, Courier, monospace;">if xpac/20 =int(xpac/20) and ypac/25=int(ypac/25)then</span><br />
<span style="font-family: Courier New, Courier, monospace;"> xcell=int((xpac)/20)</span><br />
<span style="font-family: Courier New, Courier, monospace;"> ycell=int(ypac/25)</span><br />
<span style="font-family: Courier New, Courier, monospace;"> self$ = area$[ycell,xcell]</span><br />
<span style="font-family: Courier New, Courier, monospace;"> lef$ = area$[ycell,xcell-1]</span><br />
<span style="font-family: Courier New, Courier, monospace;"> righ$ = area$[ycell,xcell+1]</span><br />
<span style="font-family: Courier New, Courier, monospace;"> up$ = area$[ycell-1,xcell]</span><br />
<span style="font-family: Courier New, Courier, monospace;"> down$ = area$[ycell+1,xcell]</span><br />
<span style="font-family: Courier New, Courier, monospace;"># Key controls</span><br />
<span style="font-family: Courier New, Courier, monospace;"> z = key</span><br />
<span style="font-family: Courier New, Courier, monospace;"> if z = 16777235 and up$<>"H" then</span><br />
<span style="font-family: Courier New, Courier, monospace;"> yspeed = -1</span><br />
<span style="font-family: Courier New, Courier, monospace;"> xspeed = 0</span><br />
<span style="font-family: Courier New, Courier, monospace;"> end if</span><br />
<span style="font-family: Courier New, Courier, monospace;"> if z = 16777237 and down$<>"H" then</span><br />
<span style="font-family: Courier New, Courier, monospace;"> yspeed = 1</span><br />
<span style="font-family: Courier New, Courier, monospace;"> xspeed = 0</span><br />
<span style="font-family: Courier New, Courier, monospace;"> end if</span><br />
<span style="font-family: Courier New, Courier, monospace;"> if z = 16777234 and lef$<>"H" then </span><br />
<span style="font-family: Courier New, Courier, monospace;"> xspeed = -1</span><br />
<span style="font-family: Courier New, Courier, monospace;"> yspeed = 0</span><br />
<span style="font-family: Courier New, Courier, monospace;"> end if</span><br />
<span style="font-family: Courier New, Courier, monospace;"> if z = 16777236 and righ$<>"H" then</span><br />
<span style="font-family: Courier New, Courier, monospace;"> xspeed = 1</span><br />
<span style="font-family: Courier New, Courier, monospace;"> yspeed = 0</span><br />
<span style="font-family: Courier New, Courier, monospace;"> end if</span><br />
<span style="font-family: Courier New, Courier, monospace;"># to stop when crashing the wall</span><br />
<span style="font-family: Courier New, Courier, monospace;"> if up$="H" and yspeed=-1 then yspeed=0</span><br />
<span style="font-family: Courier New, Courier, monospace;"> if down$="H" and yspeed=1 then yspeed=0</span><br />
<span style="font-family: Courier New, Courier, monospace;"> if lef$="H" and xspeed=-1 then xspeed=0</span><br />
<span style="font-family: Courier New, Courier, monospace;"> if righ$="H" and xspeed=1 then xspeed=0</span><br />
<span style="font-family: Courier New, Courier, monospace;"># adding points </span><br />
<span style="font-family: Courier New, Courier, monospace;"> if self$="*" then </span><br />
<span style="font-family: Courier New, Courier, monospace;"> area$[ycell,xcell]=" "</span><br />
<span style="font-family: Courier New, Courier, monospace;"> Score = Score+1</span><br />
<span style="font-family: Courier New, Courier, monospace;"> end if</span><br />
<span style="font-family: Courier New, Courier, monospace;"> if self$="@" then </span><br />
<span style="font-family: Courier New, Courier, monospace;"> area$[ycell,xcell]=" "</span><br />
<span style="font-family: Courier New, Courier, monospace;"> Score = Score+5</span><br />
<span style="font-family: Courier New, Courier, monospace;"> end if</span><br />
<span style="font-family: Courier New, Courier, monospace;">end if</span><br />
<span style="font-family: Courier New, Courier, monospace;"># transportation left to right </span><br />
<span style="font-family: Courier New, Courier, monospace;">IF xpac = 10 THEN xpac = 435</span><br />
<span style="font-family: Courier New, Courier, monospace;">IF xpac = 440 THEN xpac = 20</span><br />
<span style="font-family: Courier New, Courier, monospace;"># changing position</span><br />
<span style="font-family: Courier New, Courier, monospace;">xpac = xpac+xspeed</span><br />
<span style="font-family: Courier New, Courier, monospace;">ypac = ypac+yspeed</span><br />
<span style="font-family: Courier New, Courier, monospace;"># Drawing packman</span><br />
<span style="font-family: Courier New, Courier, monospace;">color white</span><br />
<span style="font-family: Courier New, Courier, monospace;">if xspeed = 1 then direc=1.57</span><br />
<span style="font-family: Courier New, Courier, monospace;">if xspeed = -1 then direc=-1.57</span><br />
<span style="font-family: Courier New, Courier, monospace;">if yspeed = 1 then direc= 3.14</span><br />
<span style="font-family: Courier New, Courier, monospace;">if yspeed = -1 then direc= 0</span><br />
<span style="font-family: Courier New, Courier, monospace;">if yspeed+xspeed<>0 then mouth=mouth+.2</span><br />
<span style="font-family: Courier New, Courier, monospace;">pie xpac,ypac+5,20,20,direc+sin (mouth),6.28-2*sin (mouth)</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"># Writing scores and lifes</span><br />
<span style="font-family: Courier New, Courier, monospace;">color black</span><br />
<span style="font-family: Courier New, Courier, monospace;">rect 520,60,100,30</span><br />
<span style="font-family: Courier New, Courier, monospace;">rect 520,260,100,30</span><br />
<span style="font-family: Courier New, Courier, monospace;">color white</span><br />
<span style="font-family: Courier New, Courier, monospace;">text 520,60,Score</span><br />
<span style="font-family: Courier New, Courier, monospace;">text 520,260,life</span><br />
<span style="font-family: Courier New, Courier, monospace;">return</span><br />
<br />
<br />
<br /></div>
Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-7599358500088415833.post-84499282493592334302014-11-18T06:58:00.002-08:002014-11-18T10:16:35.715-08:00Bouncy maze<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-_WMQFxAsbmA/VGuMYCsF5HI/AAAAAAAAAhY/sX4ryixKWY0/s1600/Bouncy%2Bmaze.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="http://3.bp.blogspot.com/-_WMQFxAsbmA/VGuMYCsF5HI/AAAAAAAAAhY/sX4ryixKWY0/s1600/Bouncy%2Bmaze.png" height="158" width="200" /></a></div>
<span style="font-family: Courier New, Courier, monospace;"><b><br /></b></span>
<span style="font-family: Courier New, Courier, monospace;"><b><br /><br /><br /><br /></b></span>
<span style="font-family: Courier New, Courier, monospace;"><b><br /></b></span>
<span style="font-family: Courier New, Courier, monospace;"><b>levels=5</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>fastgraphics</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>graphsize 600,600</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>clg</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>dim board$ (16,levels)</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>board$ [0,0]= "xxxxxxxxxxxxxxxxxxxxxxxxxx"</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>board$ [1,0]= "x x"</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>board$ [2,0]= "x x"</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>board$ [3,0]= "x xxxxxxxxxxxxxxxx x"</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>board$ [4,0]= "x x x"</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>board$ [5,0]= "x x x"</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>board$ [6,0]= "xxxxxxxxxxxxxxx x x"</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>board$ [7,0]= "x x x"</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>board$ [8,0]= "x x x"</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>board$ [9,0]= "x xxxxxxxxxxx x"</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>board$ [10,0]="x x x x"</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>board$ [11,0]="x x x x"</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>board$ [12,0]="x x x x x x"</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>board$ [13,0]="x x x"</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>board$ [14,0]="x x x"</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>board$ [15,0]="xxxxxxxxxxxxxxxxxxxxxxxxxx"</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>font "courier" ,25,200</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>#initial speed and position</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>px=100</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>py=140</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>ax=2</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>ay=2</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b># main loop</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>do</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>for y = 0 to 15</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>text 0,y*25,board$[y,0]</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>next y</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b><br /></b></span>
<span style="font-family: Courier New, Courier, monospace;"><b>circle px,py,10</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>refresh</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>clg</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>if mid(board$[floor(py/25-.2),0],ceil(px/19+0.4),1)="x" then</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>ax=-ax</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>end if</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>if mid(board$[floor(py/25-.2),0],ceil(px/19+0.2),1)="x" then</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>ax=-ax</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>end if</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>if mid(board$[floor(py/25-.1),0],ceil(px/19+0.3),1)="x" then</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>ay=-ay</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>end if</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>if mid(board$[floor(py/25-.3),0],ceil(px/19+0.3),1)="x" then</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>ay=-ay</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>end if</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>px=px+ax</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>py=py+ay</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b>until 3=2</b></span></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7599358500088415833.post-68264246122035576292014-11-15T05:32:00.005-08:002014-11-15T05:32:58.287-08:00Report generator for busy teachers<div dir="ltr" style="text-align: left;" trbidi="on">
for n = 0 to 10<br />
pause 0.01<br />
print "Benny ";<br />
a=int(rand*3)<br />
if a=0 then print "evolves ";<br />
if a=1 then print "develops his work ";<br />
if a=2 then print "has improved ";<br />
a=int(rand*5)<br />
if a=0 then print "brilliantely";<br />
if a=1 then print "fantasticaly";<br />
if a=2 then print "very well";<br />
if a=3 then print "exeptionally";<br />
if a=4 then print "with exellence";<br />
print ". The homework is ";<br />
a=int(rand*5)<br />
if a=0 then print "marvellous.";<br />
if a=1 then print "a true wonder.";<br />
if a=2 then print "outstanding.";<br />
if a=3 then print "unique.";<br />
if a=4 then print "beautifull.";<br />
a=int(rand*3)<br />
if a=0 then print "We trust ";<br />
if a=1 then print "We assume ";<br />
if a=2 then print "We believe ";<br />
a=int(rand*4)<br />
if a=0 then print "he will achive ";<br />
if a=1 then print "he is going to get ";<br />
if a=2 then print "he will get ";<br />
if a=3 then print "he is going to attain ";<br />
a=int(rand*4)<br />
if a=0 then print "fantastic results."<br />
if a=1 then print "high grades."<br />
if a=2 then print "lots of As."<br />
if a=3 then print "tonnes of A*s."<br />
next n</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7599358500088415833.post-82154398931278967122014-03-05T03:33:00.001-08:002014-03-08T05:41:52.998-08:00Flappy Ball<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-oxBaxYxuep0/UxcKjllPaVI/AAAAAAAAAew/JZNUUiC3F-4/s1600/flappy.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="http://4.bp.blogspot.com/-oxBaxYxuep0/UxcKjllPaVI/AAAAAAAAAew/JZNUUiC3F-4/s1600/flappy.png" height="173" width="200" /></a></div>
# Minimalist version of flappy bird, Work in progress<br />
# Click to jump<br />
graphsize 600,400<br />
fastgraphics<br />
Dim obstaclehight(10)<br />
birdy=200<br />
dy=-1<br />
lifes=3<br />
<br />
for level = 1 to 5<br />
# Generate obstacles<br />
for n = 0 to 9<br />
obstaclehight[n] = 150+ int(rand*(10+40*level))-20*level<br />
next n<br />
# restart point after losing a life<br />
start:<br />
# End game code<br />
if lifes = 0 then<br />
color black<br />
font "arial",50,50<br />
text 50,50,"End"<br />
refresh<br />
end<br />
end if<br />
pause 1<br />
# Running code<br />
for x = 1 to 2200 step 1<br />
color yellow<br />
rect 0,0,600,400<br />
color black<br />
font "arial",50,50<br />
text 50-x,50,"Level:"+(level)<br />
if level < 5 then text 2200-x,50,"Level:"+(level+1)<br />
if level = 5 then text 2200-x,50,"End"<br />
# Drawing columns<br />
for n = 0 to 9<br />
color darkgreen<br />
rect 300+n*200-x,0,50,400<br />
color yellow<br />
rect 300+n*200-x,obstaclehight[n],50,100<br />
# Ball death<br />
if 300+n*200-x=50 or 300+n*200-x=0 then<br />
if birdy < obstaclehight[n] or birdy > obstaclehight[n]+100 then<br />
lifes=lifes-1<br />
goto start<br />
end if<br />
end if<br />
next n<br />
# Ball draw<br />
color red<br />
circle 50,birdy,10<br />
color white<br />
circle 52,birdy-2,3<br />
color black<br />
circle 53,birdy-2,2<br />
rect 56,birdy+2,5,3<br />
color black<br />
font "arial",20,100<br />
text 10,10,"Lifes"+lifes<br />
# Movement <br />
birdy=birdy+dy<br />
dy=dy+.015<br />
if clickx>0 then dy=-1<br />
clickclear<br />
refresh<br />
next x<br />
next level<br />
end</div>
Unknownnoreply@blogger.com6tag:blogger.com,1999:blog-7599358500088415833.post-59003827507087499992014-01-07T08:27:00.002-08:002014-01-10T06:15:10.527-08:003D Ball<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-SBxU4gNjdzg/UKAXkLZfXUI/AAAAAAAAANM/8C0sdqFDR9E/s1600/Bounce.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="http://3.bp.blogspot.com/-SBxU4gNjdzg/UKAXkLZfXUI/AAAAAAAAANM/8C0sdqFDR9E/s1600/Bounce.png" height="179" width="200" /></a># Based in an example program, a retake on a 3D simulation</div>
graphsize 500,500<br />
vx=.002<br />
vy=.003<br />
vz=.005<br />
xball=1<br />
yball=1<br />
zball=1<br />
while 1=1<br />
a = mousex / 200<br />
b = mousey / 200<br />
gosub update<br />
end while<br />
update:<br />
fastgraphics<br />
clg<br />
x=0<br />
y=2<br />
z=0<br />
gosub matrix<br />
x1=sx<br />
y1=sy<br />
x=2<br />
y=0<br />
z=0<br />
gosub matrix<br />
x2=sx<br />
y2=sy<br />
x=2<br />
y=2<br />
z=0<br />
gosub matrix<br />
x3=sx<br />
y3=sy<br />
color darkgreen<br />
poly{200,200,x1,y1,x3,y3,x2,y2}<br />
xball=xball+vx<br />
yball=yball+vy<br />
zball=zball+vz<br />
vz=vz-.0005<br />
if xball>2 then vx=-vx<br />
if xball<0 then vx=-vx<br />
if yball>2 then vy=-vy<br />
if yball<0 then vy=-vy<br />
if zball<0 then vz=-vz*.98<br />
color black<br />
x=xball<br />
y=yball<br />
z=0<br />
gosub matrix<br />
chord sx,sy,10,5-((y1+y2+y3)/100),0,pi*2<br />
color red<br />
x=xball<br />
y=yball<br />
z=zball<br />
gosub matrix<br />
circle sx,sy,5<br />
<br />
if y3<200 then<br />
color darkyellow<br />
poly{200,200,x1,y1,x3,y3,x2,y2}<br />
end if<br />
refresh<br />
clg<br />
return<br />
matrix:<br />
u = x<br />
v = y<br />
w = z<br />
u2 = u * cos(a) - v * sin(a)<br />
v2 = u * sin(a) + v * cos(a)<br />
w2 = w<br />
u = u2<br />
v = v2<br />
w = w2<br />
u2 = u<br />
v2 = v * cos(b) - w * sin(b)<br />
w2 = v * sin(b) + w * cos(b)<br />
u = u2<br />
v = v2<br />
w = w2<br />
sx = 200+u * (w + 2) * 35<br />
sy = 200+v * (w + 2) * 35<br />
return</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7599358500088415833.post-81698973656969272022013-12-14T14:29:00.001-08:002016-04-14T04:30:00.635-07:00Bucktooth Bunny<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-yy0qsOKHFpY/UqzZfHnSwVI/AAAAAAAAAd4/fU08su3V80Y/s1600/Bunny.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="https://1.bp.blogspot.com/-yy0qsOKHFpY/UqzZfHnSwVI/AAAAAAAAAd4/fU08su3V80Y/s1600/Bunny.png" /></a></div>
<br />
# Khan academy is a brilliant educational site . You can learn everything there including programming . This is the Basic256 version of the bucktooth bunny. As you can see from the link below the code is very similar to the one used in Khan academy wich is based in Javascript.<br />
#<span style="color: blue;"> <a href="https://www.khanacademy.org/cs/programming/variables/p/challenge-bucktooth-bunny">https://www.khanacademy.org/cs/programming/variables/p/challenge-bucktooth-bunny</a></span><br />
<br />
arc(150-25, 70-60, 60, 120,0,2*pi) # left ear<br />
arc(240-25, 70-60, 60, 120,0,2*pi) # right ear<br />
color (black,white)<br />
circle(200, 170, 75) # face<br />
rect(185, 200, 15, 10) # left tooth<br />
rect(200, 200, 15, 10) # right tooth<br />
color (black,black)<br />
circle(170, 150, 5) # left eye<br />
circle(230, 150, 5) # right eye<br />
<br />
line(150, 200, 250, 200) # mouth</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7599358500088415833.post-29907988641717526232013-12-14T13:05:00.003-08:002013-12-14T14:18:26.425-08:00Marbles Game<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-v83jv48pFMY/UqzHrfmwQ2I/AAAAAAAAAdc/GiCZ6GnL2nM/s1600/Marbles.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="http://4.bp.blogspot.com/-v83jv48pFMY/UqzHrfmwQ2I/AAAAAAAAAdc/GiCZ6GnL2nM/s1600/Marbles.png" height="199" width="320" /></a></div>
<br />
# This is a big one . Clean of most bugs but there are still a few<br />
Fastgraphics<br />
# graphics window size<br />
graphsize 800,600<br />
clg<br />
fastgraphics<br />
rem initial variables<br />
nball=20<br />
Dim x(nball)<br />
Dim y(nball)<br />
Dim vx(nball)<br />
Dim vy(nball)<br />
Dim mass(nball)<br />
Dim colisionflag(nball,nball)<br />
Dim bounceflag(nball)<br />
ed=1<br />
out=0<br />
turn=1<br />
<br />
# One can change the order of the levels here<br />
gosub first<br />
gosub waitfordirection<br />
gosub new<br />
gosub two<br />
gosub waitfordirection<br />
gosub new<br />
gosub three<br />
gosub waitfordirection<br />
gosub new<br />
gosub four<br />
gosub waitfordirection<br />
gosub new<br />
gosub five<br />
gosub waitfordirection<br />
color white<br />
font "arial",50,100<br />
Text 170,200,"Hurray"<br />
refresh<br />
end<br />
end<br />
<br />
<br />
# These are the 5 levels it is easy to make more<br />
first:<br />
balls=2<br />
tries=2<br />
mass[0]=10: x[0]=250: y[0]=250<br />
mass[1]=10: x[1]=100: y[1]=100<br />
mass[2]=10: x[2]=400: y[2]=400<br />
return<br />
<br />
two:<br />
balls=4<br />
tries=4<br />
mass[0]=10: x[0]=100: y[0]=100<br />
mass[1]=10: x[1]=150: y[1]=150<br />
mass[2]=10: x[2]=200: y[2]=200<br />
mass[3]=10: x[3]=250: y[3]=250<br />
mass[10]=20: x[10]=300: y[10]=300<br />
return<br />
<br />
three:<br />
balls=5<br />
tries=4<br />
mass[0]=10: x[0]=100: y[0]=100<br />
mass[1]=10: x[1]=200: y[1]=200<br />
<br />
mass[3]=10: x[3]=400: y[3]=400<br />
mass[10]=20: x[10]=400: y[10]=300<br />
mass[11]=20: x[11]=350: y[11]=350<br />
mass[12]=20: x[12]=250: y[12]=250<br />
return<br />
<br />
four:<br />
balls=8<br />
tries=6<br />
mass[0]=10: x[0]=250: y[0]=250<br />
mass[1]=10: x[1]=150: y[1]=150<br />
mass[2]=10: x[2]=350: y[2]=350<br />
mass[3]=10: x[3]=400: y[3]=100<br />
mass[4]=10: x[4]=100: y[4]=400<br />
<br />
mass[10]=20: x[10]=100: y[10]=100<br />
mass[11]=20: x[11]=400: y[11]=400<br />
mass[12]=20: x[12]=150: y[12]=350<br />
mass[13]=20: x[13]=350: y[13]=150<br />
return<br />
<br />
<br />
five:<br />
balls=8<br />
tries=7<br />
mass[0]=10: x[0]=250: y[0]=250<br />
mass[1]=10: x[1]=100: y[1]=100<br />
mass[2]=10: x[2]=400: y[2]=400<br />
mass[3]=10: x[3]=400: y[3]=100<br />
mass[4]=10: x[4]=100: y[4]=400<br />
<br />
mass[10]=20: x[10]=150: y[10]=150<br />
mass[11]=20: x[11]=350: y[11]=350<br />
mass[12]=20: x[12]=150: y[12]=350<br />
mass[13]=20: x[13]=350: y[13]=150<br />
return<br />
<br />
<br />
# Initializes the scenaries<br />
new:<br />
for u = 0 to 19<br />
mass[u]=0: x[u]=0: y[u]=0<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
next u<br />
return<br />
<br />
waitfordirection:<br />
do<br />
clickclear<br />
refresh<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>do<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>gosub drawtable<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>for u = 0 to 19<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dx=mousex-x[0]<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dy=mousey-y[0]<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>gosub drawball<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>next u<br />
<br />
#cue<br />
color white<br />
line mousex+100*dx,mousey+100*dy,x[0],y[0]<br />
color red<br />
line mousex,mousey,x[0],y[0]<br />
circle mousex,mousey,3<br />
refresh<br />
dist=(dx^2+dy^2)^.5<br />
vx[0]=(clickx-x[0])*dist/10000<br />
vy[0]=(clicky-y[0])*dist/10000<br />
until clicky >0<br />
gosub round<br />
until out = balls or tries = 0<br />
turn=turn+1<br />
out=0<br />
return<br />
<br />
<br />
round:<br />
tries=tries-1<br />
do<br />
gosub drawtable<br />
for u = 0 to 19<br />
# balls out<br />
goingout=false<br />
if mass[u]>0 and (x[u]>450 or x[u]<50 or y[u]>450 or y[u]<50) then<br />
goingout=true<br />
mass[u]=mass[u]-1<br />
if mass[u]=0 then<br />
goingout=true<br />
out = out + 1<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>vx[u]=0<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>vy[u]=0<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>y[u]=0<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>x[u]=0<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>end if<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span># White out<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if u = 0 then gosub finish<br />
end if<br />
<br />
# drag<br />
vx[u]=vx[u]*0.993<br />
vy[u]=vy[u]*0.993<br />
x[u]=x[u]+vx[u]<br />
y[u]=y[u]+vy[u]<br />
# draw<br />
gosub drawball<br />
next u<br />
refresh<br />
gosub colision<br />
total_speed=0<br />
<br />
for marble = 0 to 19<br />
total_speed=total_speed+abs(vx[marble])+abs(vy[marble])<br />
next marble<br />
until total_speed<1 and goingout=false<br />
if tries = 0 and out < balls then gosub finish<br />
# reset the marble for the next round<br />
for marble = 0 to 19<br />
vx[marble]=0<br />
vy[marble]=0<br />
next marble<br />
return<br />
<br />
finish:<br />
color white<br />
font "arial",50,100<br />
Text 170,200,"Oops"<br />
refresh<br />
end<br />
return<br />
<br />
drawtable:<br />
color blue<br />
rect 0,0,800,600<br />
for grad=1 to 10<br />
color rgb (0,83+4*grad,0)<br />
rect 50+grad,50+grad,400-grad*2,400-grad*2<br />
rect 500+grad,50+grad, 250-grad*2,400-grad*2<br />
next grad<br />
<br />
<br />
color rgb (0,83,0)<br />
font "arial",22,100<br />
Text 530,70, "Round nº :"+turn<br />
Text 530,120,"Shots left :"+tries<br />
Text 530,170,"____________"<br />
Text 530,220,"Shoot the"<br />
Text 530,270,"yellow balls"<br />
Text 530,320,"out of the mat"<br />
return<br />
<br />
<br />
drawball:<br />
font "arial",8,100<br />
if mass[u]>0 then<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>for k = 1 to mass[u]<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>color rgb (200*(1.2-1/k),200*(1.2-1/k),0)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if u = 0 then color rgb ( 200*(1.2-1/k), 200*(1.2-1/k), 200*(1.2-1/k))<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>circle x[u],y[u],mass[u]-k<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>next k<br />
end if<br />
<br />
return<br />
<br />
colision:<br />
rem collision detection<br />
for u1 = 0 to 18<br />
for u2 = u1+1 to 19<br />
dx = x[u2]-x[u1]<br />
dy = y[u2]-y[u1]<br />
distance = (dx*dx+dy*dy)^.5<br />
if distance < (mass[u1]+mass[u2])and x[u2]<450 and x[u2]>50 and y[u2]<450 and y[u2]>50 then<br />
if colisionflag[u1,u2]=0 then<br />
rem vx and vy calc<br />
sound 1000,7<br />
ax=dx/distance<br />
ay=dy/distance<br />
va1=vx[u1]*ax+vy[u1]*ay<br />
vb1=-vx[u1]*ay+vy[u1]*ax<br />
va2=vx[u2]*ax+vy[u2]*ay<br />
vb2=-vx[u2]*ay+vy[u2]*ax<br />
vaP1=va1 + (1+ed)*(va2-va1)/(1+mass[u1]/mass[u2])<br />
vaP2=va2 + (1+ed)*(va1-va2)/(1+mass[u2]/mass[u1])<br />
vx[u1]=vaP1*ax-vb1*ay<br />
vy[u1]=vaP1*ay+vb1*ax<br />
vx[u2]=vaP2*ax-vb2*ay<br />
vy[u2]=vaP2*ay+vb2*ax<br />
colisionflag[u1,u2]=1<br />
end if<br />
else<br />
colisionflag[u1,u2]=0<br />
end if<br />
next u2<br />
next u1<br />
return</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7599358500088415833.post-53731477123906217232013-11-24T08:57:00.000-08:002013-11-24T08:57:20.481-08:00Matching Cards<div dir="ltr" style="text-align: left;" trbidi="on">
# Another game for the interactive whiteboard<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-7597xvEVyfM/UpIu4AW36qI/AAAAAAAAAbU/vK3CAJIOFDU/s1600/Cards.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="151" src="http://3.bp.blogspot.com/-7597xvEVyfM/UpIu4AW36qI/AAAAAAAAAbU/vK3CAJIOFDU/s200/Cards.png" width="200" /></a></div>
<br />
Dim a$(4,3)<br />
Dim value(4,3)<br />
Dim pair(2)<br />
Dim pair$(2)<br />
font "arial",40,40<br />
Graphsize 750,450<br />
time = second+minute*60+hour*3600<br />
QA = 0<br />
# Atributing questions and answers########<br />
do<br />
n1=int(rand*9+1)<br />
n2=int(rand*9+1)<br />
question$=n1+"x"+n2<br />
answer$ = string (n1*n2)<br />
#################################<br />
repetition = false<br />
#checking for repetitions<br />
for n=0 to 2<br />
for m=0 to 3<br />
if a$[m,n]=answer$ then repetition = true<br />
next m<br />
next n<br />
<br />
if repetition = false then <br />
#selecting 1 card for question<br />
Q =0<br />
do <br />
v=int(rand*3)<br />
h=int(rand*4)<br />
<br />
if a$[h,v]="" then<br />
a$[h,v]= question$<br />
value[h,v]= int(answer$)<br />
Q = 1<br />
end if<br />
until Q =1<br />
#selecting 1 card for answer<br />
A =0<br />
do <br />
v=int(rand*3)<br />
h=int(rand*4)<br />
if a$[h,v]="" then<br />
a$[h,v]= answer$<br />
value[h,v]= int(answer$)<br />
A = 1<br />
end if<br />
until A =1<br />
QA =QA +2<br />
end if<br />
until QA = 12<br />
<br />
<br />
# Clicking the cards<br />
cards=12<br />
do<br />
gosub drawcards<br />
p=0<br />
do<br />
clickclear<br />
t=0<br />
do<br />
if second+minute*60+hour*3600>t then<br />
color white<br />
rect 600,0,450,150<br />
color black<br />
text 600,40,second+minute*60+hour*3600 - time+" sec"<br />
t=second+minute*60+hour*3600<br />
end if<br />
until clicky>0<br />
x=int(clickx/150)<br />
y=int(clicky/150)<br />
pair[p]=value[x,y]<br />
pair$[p]=a$[x,y]<br />
p=p+1<br />
color red <br />
circle 150*x+20,150*y+20,10<br />
until p=2 <br />
pause .5<br />
<br />
if pair[0]=pair[1]and pair$[0]<>pair$[1] then <br />
for n=0 to 3<br />
for m=0 to 2<br />
if value[n,m]=pair[1]then a$[n,m]="Yes"<br />
next m<br />
next n<br />
cards=cards-2<br />
end if<br />
until cards=0<br />
<br />
drawcards:<br />
for n=0 to 3<br />
for m=0 to 2<br />
color black<br />
if a$[n,m]="Yes" then color green<br />
Rect 150*n,150*m,140,140<br />
color white<br />
text 150*n+20,150*m+40,a$[n,m]<br />
next m<br />
next n<br />
return<br />
<br />
end </div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7599358500088415833.post-51381275452990986312013-11-01T01:41:00.000-07:002013-11-06T13:51:11.712-08:00Estimate the angle<div dir="ltr" style="text-align: left;" trbidi="on">
# This is a game designed to be played on an interactive whiteboard by two players <br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-P00dwrxc9Lg/UnNqFUPfvqI/AAAAAAAAAa8/XQcY4zmlIfQ/s1600/angles.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="94" src="http://1.bp.blogspot.com/-P00dwrxc9Lg/UnNqFUPfvqI/AAAAAAAAAa8/XQcY4zmlIfQ/s200/angles.png" width="200" /></a></div>
<br />
clg<br />
fastgraphics<br />
p1=0:p2=0<br />
Bestof = 5<br />
#Main ####################################<br />
do <br />
<br />
angle1=int(rand*360)<br />
angle2=int(rand*360)<br />
gosub drawscale<br />
gosub drawpie<br />
color white<br />
<br />
text 170,280,"A turn"<br />
refresh<br />
gosub cliked<br />
text 170,330,"Guess: "+guess+"º"<br />
refresh<br />
error1=abs(guess-angle1)<br />
pause 1<br />
<br />
text 470,280,"B turn"<br />
refresh<br />
gosub cliked<br />
text 470,330,"Guess: "+guess+"º"<br />
refresh<br />
error2=abs(guess-angle2)<br />
pause 1<br />
<br />
gosub drawscale<br />
gosub drawpie<br />
<br />
color red<br />
if error1<error2 then <br />
win=200<br />
p1=p1+1<br />
color green<br />
end if<br />
text 170,330,"Real: "+angle1+"º"<br />
text 170,380,"Error: "+error1+"º"<br />
color red<br />
if error1>error2 then <br />
win=470<br />
p2=p2+1<br />
color green<br />
end if<br />
text 470,330,"Real: "+angle2+"º"<br />
text 470,380,"Error: "+error2+"º"<br />
color green<br />
text win,150,"Winner"<br />
refresh<br />
pause 2<br />
clg<br />
until p1=Bestof or p2=Bestof<br />
#End code####################################<br />
color black<br />
if p1=5 then text 270,320,"Player A won :)"<br />
if p2=5 then text 270,320,"Player B won :)"<br />
refresh<br />
end<br />
#Subroutines###################################<br />
cliked:<br />
clickclear<br />
do<br />
guess=mousey-7<br />
until clicky>0<br />
return<br />
<br />
drawpie:<br />
font "arial",30,100<br />
text 170,10, "Palyer A: "+p1<br />
text 470,10, "Player B: "+p2<br />
color orange<br />
pie ( 150,70,200,200,0,pi*angle1/180 )<br />
color blue<br />
pie ( 450,70,200,200,0,pi*angle2/180 )<br />
return<br />
<br />
drawscale:<br />
font "arial",10,100<br />
color black<br />
graphsize 800,600<br />
rect 0,0,800,600<br />
color white<br />
for y = 0 to 360 step 20<br />
text 10,y,y<br />
line 30,y+7,100,y+7<br />
text 775,y,y<br />
line 700,y+7,770,y+7<br />
next y<br />
refresh<br />
return</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7599358500088415833.post-79111152972856907762013-10-22T12:39:00.002-07:002013-10-22T12:39:28.367-07:00Nim (with levels)<div dir="ltr" style="text-align: left;" trbidi="on">
#After complaints I added some levels to the game<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-GweZxv-huX4/UVVaSJaNk0I/AAAAAAAAAWY/bP6IbR9WM4U/s1600/Nim.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="200" src="http://4.bp.blogspot.com/-GweZxv-huX4/UVVaSJaNk0I/AAAAAAAAAWY/bP6IbR9WM4U/s200/Nim.png" width="188" /></a></div>
<br />
#Take as many pieces you want from one of the piles <br />
<br />
#The one who takes the last piece wins<br />
<br />
Print "Click to select the collumn and the number of pieces to remove "<br />
Print "Who takes the last wins "<br />
fastgraphics<br />
graphsize 400,420<br />
font("arial",17,100)<br />
a=0<br />
b=0<br />
c=0<br />
d=0<br />
level$ = prompt("What level 3-7")<br />
level = int(level$)<br />
if level >6 then a=7<br />
if level >5 then b=6<br />
if level >4 then c=5<br />
if level >3 then d=4<br />
e=3<br />
f=2<br />
g=1<br />
<br />
for turn = 1 to 1000<br />
gosub draw<br />
if a+b+c+d+e+f+g=0 then <br />
color white<br />
alert ( "Computer (me) won")<br />
refresh<br />
end<br />
end if<br />
<br />
refresh<br />
<br />
if turn=1 then<br />
ans = confirm("Do you want to play first y/n? ")<br />
if ans then Print "Start"<br />
<br />
if not (ans) then<br />
gosub Computerplay<br />
gosub draw<br />
refresh<br />
end if<br />
end if<br />
<br />
gosub humanplay<br />
gosub draw<br />
<br />
if a+b+c+d+e+f+g=0 then <br />
alert ("You won")<br />
refresh<br />
end<br />
end if<br />
<br />
refresh<br />
gosub Computerplay<br />
next turn<br />
<br />
Computerplay:<br />
thought =0<br />
wining=false<br />
do<br />
thought=thought+1<br />
<br />
do<br />
at=a<br />
bt=b<br />
ct=c<br />
dt=d<br />
et=e<br />
ft=f<br />
gt=g<br />
pile = int(rand*7)<br />
If pile = 0 then at=at-int(rand*at)-1<br />
If pile = 1 then bt=bt-int(rand*bt)-1<br />
If pile = 2 then ct=ct-int(rand*ct)-1<br />
If pile = 3 then dt=dt-int(rand*dt)-1<br />
If pile = 4 then et=et-int(rand*et)-1<br />
If pile = 5 then ft=ft-int(rand*ft)-1<br />
If pile = 6 then gt=gt-int(rand*gt)-1<br />
until (at>-1) and (bt>-1) and (ct>-1)and(dt>-1) and (et>-1) and (ft>-1)and (gt>-1)<br />
<br />
a$ = toradix (at+8,2)<br />
b$ = toradix (bt+8,2)<br />
c$ = toradix (ct+8,2)<br />
d$ = toradix (dt+8,2)<br />
e$ = toradix (et+8,2)<br />
f$ = toradix (ft+8,2)<br />
g$ = toradix (gt+8,2)<br />
<br />
units = int (mid(a$,4,1))+int (mid(b$,4,1))+int(mid(c$,4,1))+int (mid(d$,4,1))+int (mid(e$,4,1))+int(mid(f$,4,1))+int(mid(g$,4,1))<br />
twos = int (mid(a$,3,1))+int (mid(b$,3,1))+int(mid(c$,3,1))+int (mid(d$,3,1))+int (mid(e$,3,1))+int(mid(f$,3,1))+int(mid(g$,3,1))<br />
fours = int (mid(a$,2,1))+int (mid(b$,2,1))+int(mid(c$,2,1))+int (mid(d$,2,1))+int (mid(e$,2,1))+int(mid(f$,2,1))+int(mid(g$,2,1))<br />
<br />
if units/2=int(units/2) and twos/2=int(twos/2) and fours/2=int(fours/2) then wining=true<br />
until wining=true or thought =1000<br />
a=at<br />
b=bt<br />
c=ct<br />
d=dt<br />
e=et<br />
f=ft<br />
g=gt<br />
pause 1<br />
return<br />
<br />
<br />
draw:<br />
clg<br />
color darkblue<br />
rect 0,0,400,420<br />
color grey<br />
text 33,20," A .....B.....C .....D.....E .....F .....G"<br />
for n = 1 to 7<br />
for radius = 20 to 0 step -1<br />
color rgb(255-radius*7,255-radius*7,0)<br />
if a>= n then circle 50,n*50+30,radius<br />
if b>= n then circle 100,n*50+30,radius<br />
if c>= n then circle 150,n*50+30,radius<br />
if d>= n then circle 200,n*50+30,radius<br />
if e>= n then circle 250,n*50+30,radius<br />
if f>= n then circle 300,n*50+30,radius<br />
if g>= n then circle 350,n*50+30,radius<br />
next radius<br />
next n<br />
for n = 1 to 7<br />
color black<br />
if a>= n then text 43,n*50+20,a+1-n<br />
if b>= n then text 93,n*50+20,b+1-n<br />
if c>= n then text 143,n*50+20,c+1-n<br />
if d>= n then text 193,n*50+20,d+1-n<br />
if e>= n then text 243,n*50+20,e+1-n<br />
if f>= n then text 293,n*50+20,f+1-n<br />
if g>= n then text 343,n*50+20,g+1-n<br />
next n<br />
return<br />
<br />
humanplay:<br />
p=0<br />
p$=""<br />
clickclear<br />
do<br />
if clickx >30 and clicky >60 and (clickx +clicky)<470 then<br />
if clickx<370 then p$="g"<br />
if clickx<320 then p$="f"<br />
if clickx<270 then p$="e"<br />
if clickx<220 then p$="d"<br />
if clickx<170 then p$="c"<br />
if clickx<120 then p$="b"<br />
if clickx<70 then p$="a"<br />
<br />
<br />
row=floor((clicky-55)/50)<br />
<br />
If p$ = "a" then p=a-row<br />
If p$ = "b" then p=b-row<br />
If p$ = "c" then p=c-row<br />
If p$ = "d" then p=d-row<br />
If p$ = "e" then p=e-row<br />
If p$ = "f" then p=f-row<br />
If p$ = "g" then p=g-row<br />
<br />
If p$ = "a" then a=a-p<br />
If p$ = "b" then b=b-p<br />
If p$ = "c" then c=c-p<br />
If p$ = "d" then d=d-p<br />
If p$ = "e" then e=e-p<br />
If p$ = "f" then f=f-p<br />
If p$ = "g" then g=g-p<br />
end if<br />
pause .1<br />
<br />
until p >0<br />
<br />
return</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7599358500088415833.post-15938609171106712982013-10-13T03:27:00.000-07:002013-10-14T12:20:06.615-07:00n body simulation<div dir="ltr" style="text-align: left;" trbidi="on">
# this is a n-body simulation , use arrow keys to keep it centered<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-tHu94-cbAKo/Ulp0w2G8GqI/AAAAAAAAAao/ELlh1U5oBg4/s1600/body.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="173" src="http://2.bp.blogspot.com/-tHu94-cbAKo/Ulp0w2G8GqI/AAAAAAAAAao/ELlh1U5oBg4/s200/body.png" width="200" /></a></div>
# Number of inital particles<br />
<br />
<br />
graphsize 600,600<br />
fastgraphics<br />
n=100<br />
dim x(n+1)<br />
dim y(n+1)<br />
dim xspeed(n+1)<br />
dim yspeed(n+1)<br />
dim xac(n+1)<br />
dim yac(n+1)<br />
dim mass(n+1)<br />
dim radius(n+1)<br />
# initializing variables ##############<br />
for p = 1 to n<br />
a=rand*2*pi<br />
r=rand*300<br />
x[p]=r*cos(a)+300<br />
y[p]=r*sin(a)+300<br />
s=rand*2*pi/20<br />
xspeed[p]=cos(a+s)-cos(a)<br />
yspeed[p]=sin(a+s)-sin(a)<br />
radius[p]=3<br />
mass[p]=radius[p]^3<br />
next p<br />
<br />
gravity=0<br />
dist=0<br />
colision = 0<br />
dx=0<br />
dy=0<br />
v=0<br />
h=0<br />
<br />
loop:<br />
# arrow keys####################<br />
a = key<br />
if 16777234=a then h=h-5<br />
if 16777236 =a then h=h+5<br />
if 16777237=a then v=v-5<br />
if 16777235=a then v=v+5<br />
<br />
for u = 1 to n<br />
for t = 1 to n<br />
if u<>t and mass[t]>0 and mass[u]>0 then<br />
dx=x[u]-x[t]<br />
dy=y[u]-y[t]<br />
dist=(dx^2 + dy^2)^(1/2)<br />
collide = false<br />
if dist < radius[u]+radius[t] then collide = true<br />
# gravity code################<br />
if collide = true then<br />
x[u]=(x[u]*mass[u]+x[t]*mass[t])/(mass[u]+mass[t])<br />
y[u]=(y[u]*mass[u]+y[t]*mass[t])/(mass[u]+mass[t])<br />
xspeed[u]=(xspeed[u]*mass[u]+xspeed[t]*mass[t])/(mass[u]+mass[t])<br />
yspeed[u]=(yspeed[u]*mass[u]+yspeed[t]*mass[t])/(mass[u]+mass[t])<br />
mass[u]=mass[u]+mass[t]<br />
radius[u]=mass[u]^(1/3)<br />
mass[t]=0<br />
radius[t]=0<br />
end if<br />
<br />
# colision code################<br />
if collide = false then<br />
gravity = mass[t]*mass[u]/dist^2<br />
xac[u]= gravity*dx/(1000*mass[u])<br />
yac[u]= gravity*dy/(1000*mass[u])<br />
xspeed[u]=xspeed[u]-xac[u]<br />
yspeed[u]=yspeed[u]-yac[u]<br />
x[u]=x[u]+xspeed[u]<br />
y[u]=y[u]+yspeed[u]<br />
end if<br />
###############################<br />
end if<br />
next t<br />
color white<br />
circle x[u]+h,y[u]+v,radius[u]<br />
next u<br />
refresh<br />
clg<br />
color black<br />
rect 0,0,600,600<br />
<br />
goto loop</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7599358500088415833.post-68177806206559493852013-10-09T08:35:00.003-07:002013-10-09T08:51:51.746-07:00Solid of revolution<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: left;">
<a href="http://4.bp.blogspot.com/-UeaJ4l08EsQ/UlV1o7k96GI/AAAAAAAAAaY/RXljh46MAu4/s1600/Rotation.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"></a><a href="http://4.bp.blogspot.com/-UeaJ4l08EsQ/UlV1o7k96GI/AAAAAAAAAaY/RXljh46MAu4/s1600/Rotation.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"> </a></div>
<a href="http://4.bp.blogspot.com/-UeaJ4l08EsQ/UlV1o7k96GI/AAAAAAAAAaY/RXljh46MAu4/s1600/Rotation.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="200" src="http://4.bp.blogspot.com/-UeaJ4l08EsQ/UlV1o7k96GI/AAAAAAAAAaY/RXljh46MAu4/s200/Rotation.png" width="193" /></a><br />
<br />
# This program calculates the volume of a revolution solid. The parameters are hardcoded but they are highlighted for you to change<br />
<div class="separator" style="clear: both; text-align: left;">
clg</div>
font "arial", 15,100<br />
graphsize 500,500<br />
fastgraphics<br />
#Graph Area######################<br />
xmin=-6<br />
xmax=6<br />
ymin=-5<br />
ymax=5<br />
################################<br />
tx=500/(xmax-xmin)<br />
ty=500/(ymax-ymin)<br />
area=0<br />
#x Boudaries######################<br />
bound1=-3<br />
bound2=3<br />
#################################<br />
range=bound2-bound1<br />
dx=.02<br />
Volume_solid=0<br />
for s = 0 to 2*pi step .1<br />
if s <pi then<br />
for y = ymin to ymax <br />
for x = xmin to xmax<br />
color black<br />
circle tx*x-xmin*tx, ty*y-ymin*ty,3<br />
if y=ymax+ymin then text tx*x-xmin*tx-15, ty*y-ymin*ty,x<br />
if x=0 then text tx*x-xmin*tx-15,ty*y-ymin*ty,-y+ymax+ymin<br />
next x : next y<br />
line -xmin*tx,0,-xmin*tx,500 : line 0,500+ymin*ty,500,500+ymin*ty<br />
end if<br />
for x = xmin to xmax step dx<br />
xg= tx*x-xmin*tx<br />
color red<br />
y0=y<br />
#Equation###############################<br />
y=sin(x)+2<br />
########################################<br />
yg1= 500-ty*y+ty*ymin<br />
circle xg, yg1,1<br />
#Solid<br />
if x<= bound2 and x>= bound1 then<br />
fill= 100*(sin(s))+100<br />
color rgb(200-fill,200-fill,fill)<br />
arc xg-.05*y*ty*2, yg1, .1*y*ty*2, y*ty*2,s,.1<br />
if s=0 then Volume_solid=Volume_solid+dx*(y0/2+y/2)^2*pi<br />
#Area<br />
if s <pi then<br />
color green<br />
if int(xg+1)/2 = int(xg/2+1) then line xg,yg1,xg,500+ymin*ty<br />
fill= 255*(x-bound1)/range<br />
end if<br />
end if<br />
next x<br />
refresh<br />
if s=0 then pause .5<br />
pause .02<br />
next s<br />
input "press any key",k<br />
Text 20,20, "Volume="+Volume_solid<br />
refresh</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7599358500088415833.post-23642422251239327402013-10-08T11:33:00.003-07:002013-10-09T08:47:10.157-07:00Definite integral<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-EMqLzc2MY1A/UlRQr7oor-I/AAAAAAAAAaI/mxFE1hyyoB8/s1600/Integral.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="183" src="http://2.bp.blogspot.com/-EMqLzc2MY1A/UlRQr7oor-I/AAAAAAAAAaI/mxFE1hyyoB8/s200/Integral.png" width="200" /></a></div>
# This program calculates the area between two functions the parameters functions, boundaries are hardcoded but they are highlighted for you to change<br />
<br />
<br />
<br />
<br />
<br /> font "arial", 15,100<br /> graphsize 500,500<br /> fastgraphics<br /> # Choose the dimentions of the graph#############<br /> xmin=-5<br /> xmax=5<br /> ymin=-5<br /> ymax=5<br /> ##########################################<br /> y1=0:y2=0<br /> tx=500/(xmax-xmin)<br /> ty=500/(ymax-ymin)<br /> for y = ymin to ymax <br /> for x = xmin to xmax<br />
circle tx*x-xmin*tx, ty*y-ymin*ty,3<br /> if y=ymax+ymin then text tx*x-xmin*tx-15, ty*y-ymin*ty,x<br /> if x=0 then text tx*x-xmin*tx-15, ty*y-ymin*ty,-y+ymax+ymin<br /> next x : next y<br />
line -xmin*tx,0,-xmin*tx,500 : line 0,500+ymin*ty,500,500+ymin*ty<br /> rem generate area<br />
#Choose the x boundaries#####################<br /> bound1=-2<br /> bound2=2<br /> #########################################<br /> area=0<br /> range=bound2-bound1<br /> dx=.01<br />
for x = xmin to xmax step dx<br /> xg= tx*x-xmin*tx<br /> color red<br /> p1=y1<br /> #Equation1 red#############################<br /> y1=x^2<br /> #########################################<br /> yg1= 500-ty*y1+ty*ymin<br /> circle xg, yg1,1<br /> color blue<br /> p2=y2<br /> #Equation2 blue###########################<br /> y2=x-2<br /> ########################################<br /> yg2= 500-ty*y2+ty*ymin<br /> circle xg, yg2,1<br /> if x<= bound2 and x>= bound1 then<br /> color darkgreen<br /> area=area+((y1+p1)/2-(y2+p2)/2)*dx<br /> if int(xg+1)/2 = int(xg/2+1) then line xg,yg1,xg,yg2<br /> fill= 255*(x-bound1)/range<br /> end if<br /> next x<br /> refresh<br /> input "press a key",a<br /> text 20,20,"Area="+area<br />
refresh<br />
<br /></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7599358500088415833.post-51163439587683741032013-09-26T07:45:00.002-07:002013-09-26T13:08:52.833-07:00Rock-paper-scissors<div dir="ltr" style="text-align: left;" trbidi="on">
<a href="http://4.bp.blogspot.com/-1Zvqu4ODSaE/UkRJLe5qlFI/AAAAAAAAAZo/_zT7TotbZLc/s1600/SRP.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="200" src="http://4.bp.blogspot.com/-1Zvqu4ODSaE/UkRJLe5qlFI/AAAAAAAAAZo/_zT7TotbZLc/s200/SRP.png" width="188" /></a><br />
<br />
# This is a simulation of a system based on the popular game Rock-paper-scissors<br />
<br />
<br />
<br />
clg: n=80: radius=8<br />
graphsize 600,600<br />
font "arial",10,100<br />
outputvisible ( false )<br />
fastgraphics<br />
Dim type(n):Dim xpos(n):Dim ypos(n):Dim xspeed(n):Dim yspeed(n): Dim type(n)<br />
# initial values<br />
for u = 0 to n-1<br />
a=rand<br />
xpos[u]=(rand*600):ypos[u]=(rand*400):xspeed[u]=sin(a):yspeed[u]=cos(a):type[u]=int(rand*3)<br />
next u<br />
c=0<br />
color black<br />
rect 0,410,600,190<br />
loop:<br />
for u = 0 to n-2<br />
for v = u+1 to n-1<br />
distx=(xpos[u]-xpos[v])^2<br />
disty=(ypos[u]-ypos[v])^2<br />
dist=(distx+disty)^0.5<br />
if dist<2*radius then gosub colision<br />
next v<br />
next u<br />
S=0<br />
R=0<br />
P=0<br />
c=c+1<br />
if c=600 then<br />
c=0<br />
color black<br />
rect 0,410,600,190<br />
endif<br />
for u = 0 to n-1<br />
xpos[u]=xpos[u]+ xspeed[u]<br />
ypos[u]=ypos[u]+ yspeed[u]<br />
if xpos[u]<0 then xspeed[u]=(rand/10-1.05)*xspeed[u]<br />
if ypos[u]<0 then yspeed[u]=(rand/10-1.05)*yspeed[u]<br />
if xpos[u]>600 then xspeed[u]=(rand/10-1.05)*xspeed[u]<br />
if ypos[u]>400 then yspeed[u]=(rand/10-1.05)*yspeed[u]<br />
# Drawing objects<br />
if type[u]=0 then<br />
color red<br />
circle xpos[u],ypos[u],radius<br />
color black<br />
text xpos[u]-5,ypos[u]-5,"S"<br />
S=S+1<br />
end if<br />
if type[u]=1 then<br />
color green<br />
circle xpos[u],ypos[u],radius<br />
color black<br />
text xpos[u]-5,ypos[u]-5,"R"<br />
R=R+1<br />
end if<br />
if type[u]=2 then<br />
color yellow<br />
circle xpos[u],ypos[u],radius<br />
color black<br />
text xpos[u]-5,ypos[u]-5,"P"<br />
P=P+1<br />
end if<br />
next u<br />
color red<br />
circle c,600-(180/n)*S,1<br />
color green<br />
circle c,600-(180/n)*R,1<br />
color yellow<br />
circle c,600-(180/n)*P,1<br />
refresh<br />
color white<br />
rect 0,0,600,410<br />
goto loop<br />
colision:<br />
if type[u]=0 and type[v]=1 then type[u]=1<br />
if type[v]=0 and type[u]=1 then type[v]=1<br />
if type[u]=1 and type[v]=2 then type[u]=2<br />
if type[v]=1 and type[u]=2 then type[v]=2<br />
if type[u]=2 and type[v]=0 then type[u]=0<br />
if type[v]=2 and type[u]=0 then type[v]=0<br />
return</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7599358500088415833.post-5413748276716802512013-09-24T11:26:00.001-07:002013-09-26T07:56:37.640-07:00Number Bases<div dir="ltr" style="text-align: left;" trbidi="on">
# counting in different bases<br />
graphsize 300,300<br />
font "Times New Roman",18,100<br />
fastgraphics<br />
dim base$(17)<br />
dim comp(17)<br />
for x = 1 to 2048<br />
for base = 2 to 16<br />
base$[base]=toradix(x,base)<br />
comp=length(base$[base])<br />
text 180-comp*12,20*base-42,base$[base]<br />
text 200,20*base-42,"Base "+base<br />
next base<br />
refresh<br />
clg<br />
next x</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7599358500088415833.post-36452375421192929162013-09-17T07:01:00.001-07:002013-09-25T04:38:19.860-07:00PASCAL TRIANGLE<div dir="ltr" style="text-align: left;" trbidi="on">
# I got this one from the BBC basic in Rosetta Code site<br />
font "arial",10,100<br />
graphsize 700,350<br />
nrows = 16<br />
FOR row = 1 TO nrows<br />
acc = 1<br />
FOR element = 1 TO row<br />
text element*40+350-row*20,row*20, acc+" "<br />
acc = acc * (row - element) / element<br />
NEXT element<br />
PRINT<br />
NEXT row</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7599358500088415833.post-49200919158861499092013-04-13T14:51:00.001-07:002013-04-13T14:51:56.170-07:00Cellular automation 2<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
# The cellular automation program was malfunctioning for a long time because I did not update the code for the New Basic 256 version . <br />
# This is a new version where the chaotic rule and the fractal rule are used different alternating patterns.<br />
#http://mathworld.wolfram.com/ElementaryCellularAutomaton.html<br />
<br />
fastgraphics<br />
graphsize 600,300<br />
For n = 1 to 300<br />
plot (300,1)<br />
Print "Fractal rule every "+n+" rows"<br />
For y = 1 to 300<br />
For x = 1 to 600<br />
a=0<br />
if pixel(x-1,y)=black then a=a+1<br />
if pixel(x,y)=black then a=a+10<br />
if pixel(x+1,y)=black then a=a+100<br />
<br />
if y/n = int (y/n) then <br />
gosub fractal<br />
else<br />
gosub chaotic<br />
end if<br />
<br />
next x<br />
refresh<br />
next y<br />
refresh<br />
clg<br />
next n<br />
<br />
chaotic:<br />
if a=001 or a=110 or a =010 or a=100 then plot (x,y+1)<br />
return<br />
fractal:<br />
if a=001 or a=010 or a=100 then plot (x,y+1)<br />
return<br />
</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7599358500088415833.post-25673201319881988112013-04-03T03:31:00.002-07:002013-04-05T11:59:48.453-07:00Fastest Lap<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-yKcQ89v1ki4/UVwFqgSc0CI/AAAAAAAAAYQ/ATOO6SZp4DY/s1600/Race.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="158" src="http://2.bp.blogspot.com/-yKcQ89v1ki4/UVwFqgSc0CI/AAAAAAAAAYQ/ATOO6SZp4DY/s200/Race.png" width="200" /></a></div>
# This program is just a big fat loop with a goto in the end. All the wrong stuff.<br />
<br />
graphsize(800,600)<br />
fastgraphics<br />
outputvisible (false)<br />
clg<br />
font ("arial",15,100)<br />
dim track(30)<br />
<br />
<br />
track={-14,2,-13,4,-12,5,-10,6,10,6,12,5,13,4,14,2,14,0,13,-0,12,-0,11,0,10,1,8,2,7,2,6,1,6,-4,5,-6,4,-7,2,-8,-0,-8,-2,-7,-3,-6,-4,-4,-4,-0,-5,1,-6,2,-7,2,-8,1,-9,-0,-9,-5,-10,-7,-11,-8,-12,-8,-13,-7,-14,-5,-14,2}<br />
<br />
dim car1(38)<br />
dim car2(18)<br />
car1={0,-10,-4,-9,-5,-8,-5,-4,-4,2,-4,4,-5,6,-5,9,-4,10,4,10,5,9,5,6,4,4,4,2,5,-4,5,-8,4,-9,0,-10}<br />
car2={0,-2,-1,-2,-3,-0,-3,2,0,1,3,2,3,-0,1,-2,0,-2}<br />
dim pointer (10)<br />
pointer={3,-0,0,1,-15,-0,0,-1,3,-0}<br />
<br />
dim tree(100,2)<br />
for n = 0 to 99<br />
tree [n,0]=int (rand*2200-1200)<br />
tree [n,1]=int (rand*2000-1800)<br />
next n<br />
<br />
rad = 0<br />
px=-200<br />
py=-50<br />
turn =0<br />
speed =0<br />
flag =0<br />
time =0<br />
laps=-1<br />
bestime=999<br />
init=second()+minute()*60+hour()*3600<br />
<br />
<br />
#intro####################################<br />
for n = 1 to 100 step .2<br />
penwidth(2*n)<br />
Color (black,green)<br />
clg<br />
stamp 500,250-n*5,n,2*pi*(n/100),track<br />
refresh<br />
next n<br />
penwidth(1)<br />
<br />
<br />
loop:<br />
# controls arrow keys ###################<br />
z = key<br />
if z = 16777235 then speed=speed+.1<br />
if z = 16777237 then speed=speed-.1<br />
if z = 16777234 and turn>-.2 then<br />
turn =turn-pi/90<br />
else<br />
turn=turn*.95<br />
end if<br />
if z = 16777236 and turn<.2 then turn =turn+pi/90<br />
rad = rad+turn<br />
yspeed = sin (rad)*speed<br />
xspeed = cos (rad)*speed<br />
py = py + yspeed<br />
px = px + xspeed<br />
#Track#######################<br />
color green<br />
rect 0,0,600,600<br />
color darkgreen<br />
for n = 0 to 99<br />
circle tree[n,0]-px, tree[n,1]-py,20<br />
next n<br />
Color (black,0)<br />
penwidth(200)<br />
stamp -px,-350-py,100,0,track<br />
color black<br />
penwidth(1)<br />
color white<br />
rect -px+300,-py+150,20,200<br />
color grey<br />
rect -px,-py+50,300,80<br />
rect -px,-py+370,300,80<br />
color black<br />
Text -px+70,-py+370,"Use arrow keys"<br />
#Car and lake #######################<br />
color red<br />
stamp 300, 300,2,rad+pi/2, car1<br />
color blue<br />
stamp 300, 300,2,rad+pi/2, car2<br />
color blue<br />
circle -px+70,-py-700,300<br />
<br />
#Result panel###############<br />
color blue<br />
rect 600,0,200,600<br />
Color (black,blue)<br />
penwidth(5)<br />
stamp 700,70,5,0,track<br />
color red<br />
circle px/20+715,py/20+102,3<br />
circle 700,200,80<br />
color white<br />
stamp 700,200,5,speed,pointer<br />
time=second()+minute()*60+hour()*3600-init<br />
text 610,300,"Time= "+time+"sec"<br />
text 610,350, "Lap count ="+laps<br />
text 610,400, "Best Time ="+bestime<br />
refresh<br />
#Car goes to grass##########<br />
grass =0<br />
if pixel(321,321)<>black then grass=grass+1<br />
if pixel(279,279)<>black then grass=grass+1<br />
if pixel(279,321)<>black then grass=grass+1<br />
if pixel(321,279)<>black then grass=grass+1<br />
if grass>2 and speed>.2 then speed = speed*.9<br />
#lapcount###########<br />
If pixel (321,300)=white then<br />
if flag=0 then<br />
laps = laps + 1<br />
flag =1<br />
init =second()+minute()*60+hour()*3600<br />
if time<bestime and laps >0 then bestime=time<br />
end if<br />
else<br />
flag = 0<br />
end if<br />
####################<br />
clg<br />
goto loop</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7599358500088415833.post-84910800962221702332013-03-28T03:53:00.001-07:002013-05-07T08:13:33.043-07:00TETRIS<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-iulPjMAV7-w/UVQh9SMSm5I/AAAAAAAAAWI/7mjlmwo9QkY/s1600/Tetris.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="295" src="http://1.bp.blogspot.com/-iulPjMAV7-w/UVQh9SMSm5I/AAAAAAAAAWI/7mjlmwo9QkY/s400/Tetris.png" width="400" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
graphsize 600,440<br /> fastgraphics<br /> font ("arial",20,100)<br />
Dim i(4):Dim j(4):Dim l(4):Dim o(4):Dim s(4):Dim t(4):Dim z(4)<br /> i = { 0x10F00, 0x12222, 0x100F0, 0x14444}<br /> j = { 0x144C0, 0x18E00, 0x16440, 0x10E20}<br /> l = {0x14460, 0x10E80, 0x1C440, 0x12E00 }<br /> o = { 0x1CC00, 0x1CC00, 0x1CC00, 0x1CC00}<br /> s = {0x106C0, 0x18C40, 0x16C00, 0x14620 }<br /> t = {0x10E40, 0x14C40, 0x14E00, 0x14640}<br /> z = { 0x10C60, 0x14C80, 0x1C600, 0x12640}<br />
Dim board(14,29)<br /> Dim stat(7)<br /> Score = 0<br /> endgame = false<br /> initialwait= 0.1<br />
# main loop for each newpiece<br /> do<br /> wait = initialwait<br /> rot=int(rand*4)<br /> shape = int (rand*7)<br /> stat[shape]=stat[shape]+1<br /> cores = int (rand*7)+1<br /> piecedown = false<br /> ypos=-1<br /> xpos=5<br />
# loop for each frame<br /> do <br /> ypos=ypos+1<br />
# controls<br /> for press = 1 to 4<br /> a = key<br /> if 16777234=a then xpos=xpos -checkmove(ref (board),a,xpos,ypos,shape$)<br /> if 16777236 = a then xpos=xpos +checkmove(ref (board),a,xpos,ypos,shape$)<br /> if 16777237=a then wait =0.01<br />
if 16777235=a then <br /> oldrot=rot<br /> rot = rot+1<br /> if rot = 4 then rot = 0<br /> gosub selectshape<br /> if checkmove(ref (board),a,xpos,ypos,shape$)=0 then<br /> rot = oldrot<br /> gosub selectshape<br /> end if<br /> end if<br />
pause wait<br /> next press<br />
# procedures<br /> gosub scorepanel<br /> gosub selectshape<br /> gosub drawboard<br /> gosub drawshape<br /> refresh<br /> until piecedown = true<br />
# these procedures are executed when a piece is down<br /> gosub newboard<br /> gosub takeline<br /> gosub takeline<br /> until endgame = true<br />
#last instructions before end of game<br /> Color white<br /> font ("arial",50,100)<br /> text 70,100, "Game Over"<br /> refresh<br /> end<br />
scorepanel:<br /> color darkgreen<br /> rect 0,0,600,450<br /> color green<br /> Text 300,20,"Use arrow keys"<br />
Text 300,60, "I .... "+stat[0]<br /> Text 300,100,"J .... "+stat[1]<br /> Text 300,140,"L .... "+stat[2]<br /> Text 300,180,"O .... "+stat[3]<br /> Text 300,220,"S .... "+stat[4]<br /> Text 300,260,"T .... "+stat[5]<br /> Text 300,300,"Z .... "+stat[6]<br /> Text 300,350,"Score .... "+Score<br /> return<br />
selectshape:<br /> if shape = 0 then shape$ = tobinary (i[rot])<br /> if shape = 1 then shape$ = tobinary (j[rot])<br /> if shape = 2 then shape$ = tobinary (l[rot])<br /> if shape = 3 then shape$ = tobinary (o[rot])<br /> if shape = 4 then shape$ = tobinary (s[rot])<br /> if shape = 5 then shape$ = tobinary (t[rot])<br /> if shape = 6 then shape$ = tobinary (z[rot])<br /> return<br />
function checkmove (ref (board),a,xpos,ypos,shape$)<br /> checkmove=1<br /> p=1<br /> For v = 1 to 4 <br /> For h = 1 to 4 <br /> p=p+1<br /> if mid(shape$,p,1)="1" then <br /> if board[xpos+h,ypos+v]>0 then checkmove=0<br /> if chr(a)="N" and (xpos+h>11 or xpos+h<2) then <br /> checkmove=0<br /> return<br /> end if<br />if a=16777236 and xpos+h>10 then checkmove=0<br /> if a=16777236 and board[xpos+h+1,ypos+v]>0 then checkmove=0<br /> if a=16777234 and xpos+h<3 then checkmove=0<br /> if a=16777234 and board[xpos+h-1,ypos+v]>0 then checkmove=0<br /> end if<br /> next h<br /> next v<br /> end function<br />
drawshape:<br /> if cores = 1 then color red<br /> if cores = 2 then color blue<br /> if cores = 3 then color yellow<br /> if cores = 4 then color orange<br /> if cores = 5 then color green<br /> if cores = 6 then color purple<br /> if cores = 7 then color white<br /> p=1<br /> For v = 1 to 4 <br /> For h = 1 to 4 <br /> p=p+1<br /> if mid(shape$,p,1)="1" then <br /> rect xpos*20+h*20,ypos*20+v*20,19,19<br /> if board[xpos+h,ypos+v+1]>0 or ypos+v=20 then piecedown=true<br /> end if<br /> next h<br /> next v<br /> if piecedown=true then <br /> if ypos<2 then endgame =true<br /> return<br /> end if<br /> return<br />
newboard:<br /> p=2<br /> For v = 1 to 4 <br /> For h = 1 to 4 <br /> if mid(shape$,p,1)="1" then board[xpos+h,ypos+v]=cores<br /> p=p+1<br /> next h<br /> next v<br /> return<br />
drawboard:<br /> For y = 1 to 20 <br /> For x = 2 to 11<br /> if board[x,y] = 1 then color red<br /> if board[x,y] = 2 then color blue<br /> if board[x,y] = 3 then color yellow<br /> if board[x,y] = 4 then color orange<br /> if board[x,y] = 5 then color green<br /> if board[x,y] = 6 then color purple<br /> if board[x,y] = 7 then color white<br /> if board[x,y]=0 then color black<br /> rect x*20,y*20,19,19<br /> next x<br /> next y<br /> return<br />
takeline:<br /> For y = 20 to 1 step -1<br /> complete = true<br /> For x = 2 to 11<br /> if board[x,y]=0 then complete = false<br /> next x<br /> if complete = true then<br /> For row = y to 1 step -1<br /> For position = 1 to 10 <br /> board[position,row]=board[position,row-1]<br /> next position<br /> next row<br /> Score = Score +1<br /> ix = initialwait*.9<br /> initialwait=ix<br /> end if<br /> next y<br /> return<br />
<br /></div>
Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-7599358500088415833.post-17395540484141647902013-01-11T11:51:00.001-08:002013-01-11T11:51:08.837-08:00Charlie<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-z_xE59icp18/UPBsjR44qNI/AAAAAAAAAVc/AJYKmO_vTlk/s1600/Charlie.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="http://4.bp.blogspot.com/-z_xE59icp18/UPBsjR44qNI/AAAAAAAAAVc/AJYKmO_vTlk/s1600/Charlie.png" /></a></div>
clg
<br />
<div style="-qt-block-indent: 0; margin: 0px; text-indent: 0px;">
penwidth 2</div>
<div style="-qt-block-indent: 0; margin: 0px; text-indent: 0px;">
color (black ,-256^2/3)</div>
<div style="-qt-block-indent: 0; margin: 0px; text-indent: 0px;">
circle 150,100,50</div>
<div style="-qt-block-indent: 0; margin: 0px; text-indent: 0px;">
arc 150,100,13,13,0,3.14</div>
<div style="-qt-block-indent: 0; margin: 0px; text-indent: 0px;">
circle 140,100,2</div>
<div style="-qt-block-indent: 0; margin: 0px; text-indent: 0px;">
circle 170,100,2</div>
<div style="-qt-block-indent: 0; margin: 0px; text-indent: 0px;">
arc 120,107,66,30,1.8,2.7</div>
<div style="-qt-block-indent: 0; margin: 0px; text-indent: 0px;">
penwidth 1</div>
<div style="-qt-block-indent: 0; margin: 0px; text-indent: 0px;">
arc 130,90,15,5,3.14*1.5,2</div>
<div style="-qt-block-indent: 0; margin: 0px; text-indent: 0px;">
arc 163,90,15,5,6,1</div>
<div style="-qt-block-indent: 0; margin: 0px; text-indent: 0px;">
arc 135,60,25,15,0,-5.14</div>
<div style="-qt-block-indent: 0; margin: 0px; text-indent: 0px;">
arc 155,60,20,15,0,5.14</div>
</div>
Unknownnoreply@blogger.com0