Dark Bit Factory & Gravity

PROGRAMMING => Other languages => Yabasic => Topic started by: bikemadness on November 08, 2021

Title: Base Count
Post by: bikemadness on November 08, 2021
2 and 10 together.

D-Pad R to go.
D-Pad L to reset.

Code: [Select]
num=10
dim k(num)

base=2 rem or whatever you like
count=base-1

x=0
move=1

open window 640,512
repeat
setdrawbuf vm
vm=1-vm
setdispbuf vm
clear window
c=peek("port1")

if and(c,32)<>0 right=1
if right=1 R=R+1
if R>2 R=2
if R=2 right=0
if and(c,32)=0 R=0

if right=1 x=x+1

if right=1 k(1)=k(1)+1

if and(c,128)<>0 left=1
if left=1 L=L+1
if L>2 L=2
if L=2 left=0
if and(c,128)=0 L=0

if left=1 x=0
if left=1 then
for a=1 to num
k(a)=0
next a
endif

'x=x+1
'if x>1000 x=1000
'if x=1000 move=0
'k(1)=k(1)+ move

if x<0 x=0

if k(1)<0 k(1)=0

for a=1 to num

if k(a)>count then
k(a)=0
k(a+1)=k(a+1)+1
endif

next a

for a=1 to num
text (a*-10)+280,150,str$(k(a))
next a

text 200,130,"base "+str$(base)
text 100,130,"base 10"
text 150-(len(str$(x))*10),150,str$(x)

until (1=0)