I once made a random music player that I knew had plenty of flaws, but it still worked.T'was 4 months ago since I last coded (yes im very very lazy) and today I decided to re-make it. I sucsessfully shortend the code to about 1/2 its original size. I think in doing that I learned a thing or two. But what I wanna know is, did I do a good job remaking, and if not, what can I do to improve?
original(343 lines):
` [[Randomization]]
randomize timer()
m#=rnd(71)
` [[Load Alot Of Music]]
print "LOADING 0%"
load music "1.mp3",1
cls
print "LOADING 1%"
load music "2.mp3",2
cls
print "LOADING 3%"
load music "3.mp3",3
cls
print "LOADING 4%"
load music "4.mp3",4
cls
print "LOADING 6%"
load music "5.mp3",5
cls
print "LOADING 7%"
load music "6.mp3",6
cls
print "LOADING 8%"
load music "7.mp3",7
cls
print "LOADING 10%"
load music "8.mp3",8
cls
print "LOADING 11%"
load music "9.mp3",9
cls
print "LOADING 13%"
load music "10.mp3",10
cls
print "LOADING 14%"
load music "11.mp3",11
cls
print "LOADING 15%"
load music "12.mp3",12
cls
print "LOADING 17%"
load music "13.mp3",13
cls
print "LOADING 18%"
load music "14.mp3",14
cls
print "LOADING 20%"
load music "15.mp3",15
cls
print "LOADING 21%"
load music "16.mp3",16
cls
print "LOADING 23%"
load music "17.mp3",17
cls
print "LOADING 24%"
load music "18.mp3",18
cls
print "LOADING 25%"
load music "19.mp3",19
cls
print "LOADING 27%"
load music "20.mp3",20
cls
print "LOADING 28%"
load music "21.mp3",21
cls
print "LOADING 30%"
load music "22.mp3",22
cls
print "LOADING 31%"
load music "23.mp3",23
cls
print "LOADING 32%"
load music "24.mp3",24
cls
print "LOADING 34%"
load music "25.mp3",25
cls
print "LOADING 35%"
load music "26.mp3",26
cls
print "LOADING 37%"
load music "27.mp3",27
cls
print "LOADING 38%"
load music "28.mp3",28
cls
print "LOADING 39%"
load music "29.mp3",29
cls
print "LOADING 41%"
load music "30.mp3",30
cls
print "LOADING 42%"
load music "31.mp3",31
cls
print "LOADING 44%"
load music "32.mp3",32
cls
print "LOADING 45%"
load music "33.mp3",33
cls
print "LOADING 46%"
load music "34.mp3",34
cls
print "LOADING 48%"
load music "35.mp3",35
cls
print "LOADING 49%"
load music "36.mp3",36
cls
print "LOADING 51%"
load music "37.mp3",37
cls
print "LOADING 52%"
load music "38.mp3",38
cls
print "LOADING 54%"
load music "39.mp3",39
cls
print "LOADING 55%"
load music "40.mp3",40
cls
print "LOADING 56%"
load music "41.mp3",41
cls
print "LOADING 58%"
load music "42.mp3",42
cls
print "LOADING 59%"
load music "43.mp3",43
cls
print "LOADING 61%"
load music "44.mp3",44
cls
print "LOADING 62%"
load music "45.mp3",45
cls
print "LOADING 63%"
load music "46.mp3",46
cls
print "LOADING 65%"
load music "47.mp3",47
cls
print "LOADING 66%"
load music "48.mp3",48
cls
print "LOADING 68%"
load music "49.mp3",49
cls
print "LOADING 69%"
load music "50.mp3",50
` [[This Is Long...]]
cls
print "LOADING 70%"
load music "51.mp3",51
cls
print "LOADING 72%"
load music "52.mp3",52
cls
print "LOADING 73%"
load music "53.mp3",53
cls
print "LOADING 75%"
load music "54.mp3",54
cls
print "LOADING 76%"
load music "55.mp3",55
cls
print "LOADING 77%"
load music "56.mp3",56
cls
print "LOADING 79%"
load music "57.mp3",57
cls
print "LOADING 80%"
load music "58.mp3",58
cls
print "LOADING 82%"
load music "59.mp3",59
cls
print "LOADING 83%"
load music "60.mp3",60
cls
print "LOADING 85%"
load music "61.mp3",61
cls
print "LOADING 86%"
load music "62.mp3",62
cls
print "LOADING 87%"
load music "63.mp3",63
cls
print "LOADING 89%"
load music "64.mp3",64
cls
print "LOADING 90%"
load music "65.mp3",65
cls
print "LOADING 92%"
load music "66.mp3",66
cls
print "LOADING 93%"
load music "67.mp3",67
cls
print "LOADING 94%"
load music "68.mp3",68
cls
print "LOADING 96%"
load music "69.mp3",69
cls
print "LOADING 97%"
load music "70.mp3",70
cls
print "LOADING 99%"
load music "71.mp3",71
cls
print "LOADING 100%"
wait 500
cls
` [[Variables]]
txt#=1
` [[Welcome Stuff]]
welcome:
print "---Welcome to my little random music player!---"
print ""
print "This program is designd to act as a radio, an "
print "alarm, and also for enjoyment. "
print ""
print "Some (or all) of the music contained in this "
print "player may not be desirable for some people. "
print ""
print "To exit the music player, just press 0 on the "
print "numpad. "
print ""
print "To go to another random music, just press 6 on "
print "the numpad. "
print ""
print "To minimize this window, press 2 on the numpad."
print ""
print "To toggle this message on or off, press 5 on "
print "the numpad. "
print ""
print "If you are using a laptop, or some kind of "
print "wierd computer without a numpad, press space. "
` [[The Loop]]
do
`[[Randomness In Loop]]
if music playing(m#)=0
m#=rnd(71)
if m#=0
m#=50
endif
play music m#
endif
`[[0 Usage]]
if keystate(82)
for m=1 to 71 step 1
delete music m
next m
end
endif
`[[6 Usage]]
if keystate(77)
stop music m#
endif
`[[5 Usage]]
if keystate(76)
if txt#=1
cls
txt#=0
else
txt#=1
goto welcome
endif
endif
`[[2 Usage]]
if keystate(80)
minimize window
endif
`[[Space Usage]]
if spacekey()
goto laptop
endif
loop
laptop:
cls
lstart:
print "---Welcome to my little random music player!---"
print ""
print "This program is designd to act as a radio, an "
print "alarm, and also for enjoyment. "
print ""
print "Some (or all) of the music contained in this "
print "player may not be desirable for some people. "
print ""
print "To exit the music player, just press the down "
print "arrowkey. "
print ""
print "To go to another random music, just press the "
print "right arrowkey. "
print ""
print "To minimize this window, press the up arrowkey."
print ""
print "To toggle this message on or off, press the "
print "left arrowkey. "
` [[2nd Loop]]
do
`[[Randomness In Loop]]
if music playing(m#)=0
m#=rnd(71)
if m#=0
m#=50
endif
play music m#
endif
`[[Down Usage]]
if downkey()
for m=1 to 71 step 1
delete music m
next m
end
endif
`[[Right Usage]]
if rightkey()
stop music m#
endif
`[[Left Usage]]
if leftkey()
if txt#=1
cls
txt#=0
else
txt#=1
goto lstart
endif
endif
`[[Up Usage]]
if upkey()
minimize window
endif
loop
Remake(173 lines):
`****************************MY RANDOM MUSIC PLAYER REMAKE!!!**********************************
` [[VARIABLES]]
m=rnd(70)+1 `<---- (the music number)
t=0 `<---- (gets the state of the message. (1 is on 0 is off))
ok=0 `<---- (gets if the message was printed)
` [[LOAD ALOT MUSIC]]
for x = 1 to 71
mnum$ = str$(x)
music$ = mnum$ + ".mp3"
load music music$,x
print "music loaded: ",x*1.408450704,"%"
cls
next x
` [[THE LOOP]]
norm:
t=1
cls
do
` [[IF STATEMEMENTS]]
`[[DO STUFF ABOUT THE MESSAGE STATE]]
if t=0
cls
ok=0
endif
if t=1
if ok=0
gosub welcome
endif
endif
`[[MAKE SURE MUSIC IS ALWAYS PLAYING W/ TOTAL RANDOMNESS]]
if music playing(m)=0
randomize timer()
m=rnd(70)+1
play music m
endif
`[[0 KEY]]
if keystate(82)
for x = 1 to 71
delete music x
next x
end
endif
`[[6 KEY]]
if keystate(77)
stop music m
endif
`[[5 KEY]]
if keystate(76)
if t = 1
t = 0
ok=0
cls
goto skip5
endif
if t = 0
t = 1
endif
endif
skip5:
`[[2 KEY]]
if keystate(80)
minimize window
endif
`[[SPACE KEY]]
if spacekey()
ok=0
cls
goto laptop
endif
loop
` [[THE AUX. LAPTOP LOOP]]
laptop:
t=1
cls
do
` [[IF STATEMEMENTS]]
`[[DO STUFF ABOUT THE MESSAGE STATE]]
if t=0
cls
ok=0
endif
if t=1
if ok=0
gosub laptopwelcome
endif
endif
`[[MAKE SURE MUSIC IS ALWAYS PLAYING W/ TOTAL RANDOMNESS]]
if music playing(m)=0
randomize timer()
m=rnd(70)+1
play music m
endif
`[[DOWN KEY]]
if downkey()
for x = 1 to 71
delete music x
next x
end
endif
`[[RIGHT KEY]]
if rightkey()
stop music m
endif
`[[LEFT KEY]]
if leftkey()
if t = 1
t = 0
ok=0
goto skipleft
cls
endif
if t = 0
t = 1
endif
endif
skipleft:
`[[UP KEY]]
if upkey()
minimize window
endif
`[[SPACE KEY]]
if spacekey()
ok=0
cls
goto norm
endif
loop
` [[SUBROUTINES]]
welcome:
print "---Welcome to my little random music player!---"
print ""
print "This program is designd to act as a radio, an "
print "alarm, and also for enjoyment. "
print ""
print "Some (or all) of the music contained in this "
print "player may not be desirable for some people. "
print ""
print "To exit the music player, just press 0 on the "
print "numpad. "
print ""
print "To go to another random music, just press 6 on "
print "the numpad. "
print ""
print "To minimize this window, press 2 on the numpad."
print ""
print "To toggle this message on or off, press 5 on "
print "the numpad. "
print ""
print "If you are using a laptop, or some kind of "
print "wierd computer without a numpad, press space. "
ok=1
return
laptopwelcome:
print "---Welcome to my little random music player!---"
print ""
print "This program is designd to act as a radio, an "
print "alarm, and also for enjoyment. "
print ""
print "Some (or all) of the music contained in this "
print "player may not be desirable for some people. "
print ""
print "To exit the music player, just press the down "
print "arrowkey. "
print ""
print "To go to another random music, just press the "
print "right arrowkey. "
print ""
print "To minimize this window, press the up arrowkey."
print ""
print "To toggle this message on or off, press the "
print "left arrowkey. "
ok=1
return
what do you think?