|
Post by David Drake on Feb 11, 2020 10:31:53 GMT -5
I wrote an LB program, of course! I think it works, anyway. Here's the short, albeit not closely checked or tested, character counter: filedialog "Open","*.*",fileName$ if fileName$<>"" then open fileName$ for input as #1 while eof(#1)<>-1 line input #1, a$ print a$ length = length+len(a$)+1 wend close #1 end if print "Length: ";length
|
|
|
Post by Rod on Feb 11, 2020 10:41:04 GMT -5
LOF() works too. But there is a difference 965 v 991 on my .bas so I vote for David's count and claim 965 edit ahh... no The line ending is CRLF so each line gets plus 2 not plus 1 so back to 991 filedialog "Open","*.*",fileName$ if fileName$<>"" then open fileName$ for input as #1 while eof(#1)<>-1 line input #1, a$ print a$ length = length+len(a$)+2 wend close #1 end if print "Length: ";length
filedialog "Open","*.*",fileName$ if fileName$<>"" then open fileName$ for input as #1 print "Length: ";lof(#1) close #1 end if
|
|
|
Post by David Drake on Feb 11, 2020 11:25:08 GMT -5
I'm with you on the character count. Didn't dawn on me the CRLF is two, not one.
In any case, I'm running into play-ability issues with the latest version. Can't land at all with difficulty level of three or higher. Keep running into invisible mountains, which did not happen before. I think the code changes have somehow altered the sprites.
|
|
|
Post by Rod on Feb 11, 2020 11:50:58 GMT -5
Ok, the sprites are now the same size as originaly but they may not look exactly the same. At level 1 I can land. And I saved another two bytes down to 989
r$="Dead":f=1:prompt "Level (1-4)?";f f=min(4,f):WindowWidth=800:WindowHeight=600 open "" for graphics_nsb_nf as #1 #1 "trapclose [b];when characterInput [k];fill blue;setfocus;down;size 2;fill blue;color red;getbmp b 0 0 800 600;place 0 20;box 20 40;getbmp j 0 0 20 40;getbmp m 18 10 5 20;getbmp n 0 0 5 20;addsprite L j;background b" lx=rnd(1)*650:x=10:y=10:dx=f:dy=f:s=350 for a=1 to 800 step 4 c=3*f*(2-rnd(1)*5) if a>lx+100/f or a<lx then s=s+c:s=Min(Max(200,s),550):#1 "addsprite M";a;" m;spritexy M";a;" ";a;" ";s else #1 "addsprite N";a;" n;spritexy N";a;" ";a;" ";s end if next a timer 500,[a] wait [a] dy=dy+1:x=x+dx:y=y+dy if x>780 or x<1 or y>580 or y<1 then [b] #1 "spritexy L ";x;" ";y;";drawsprites;spritecollides L d$" if instr(d$,"M") then [b] if instr(d$,"N") then if dy>4 or dx>2 or dx<-2 then r$="Crash" else r$="Landed":goto [b] end if:wait [k] k$=Inkey$:dy=((k$="=")*(-5))+dy:dx=((k$="[")*(-1))+(k$="]")+dx wait [b] notice r$:close #1:end
|
|
|
Post by David Drake on Feb 11, 2020 15:08:05 GMT -5
I decided that being able to actually play and enjoy the game mattered to me, so I set the color back to black and white and added the nomainwin. I also replaced some repeating drawing commands with variables, which offset the additional some. Also replaced 2-letter variables with 1-letter. Here's my latest:
nomainwin:r$="BOOM":f=1:prompt "Level 1-4";f:f=min(4,f):WindowWidth=800:WindowHeight=600:open "" for graphics_nsb_nf as #1:a$="place 1 11;turn 180;go 10;getbmp " #1 "trapclose [b];when characterInput [k];setfocus;color white;down;fill black;size 2;getbmp b 1 1 800 600;place 1 21;box 21 41;getbmp j 1 1 20 40;size 25;";a$;" m 1 1 5 20;color red;";a$;" n 1 1 5 20;addsprite L j;background b" q=rnd(1)*650:x=10:y=10:i=f:j=f:s=350:for a=1 to 800 step 4 c=3*f*(2-rnd(1)*5) if a>q+100/f or a<q then s=s+c:s=Min(Max(200,s),550):#1 "addsprite M";a;" m;spritexy M";a;" ";a;" ";s else #1 "addsprite N";a;" n;spritexy N";a;" ";a;" ";s end if next a timer 500,[a]:wait [a] j=j+1:x=x+i:y=y+j:if x>780 or x<1 or y>580 or y<1 then [b] #1 "spritexy L ";x;" ";y;";drawsprites;spritecollides L d$" if instr(d$,"M") then [b] if instr(d$,"N") then if j>5 or i>3 or i<-3 then r$="OUCH" else r$="Nice!":goto [b] end if:wait [k] k$=Inkey$:j=((k$="=")*(-5))+j:i=((k$="[")*(-1))+(k$="]")+i:wait [b] notice r$:close #1:end
|
|
|
Post by Rod on Feb 11, 2020 18:45:05 GMT -5
You might recover the losses by getting rid of c and in-lining the code at s=s+c you could also replace the for next step with while a<800 a=a+4 wend. Is the limit checking of s needed? Should get you below 1000 but your comfortably inside 1024.
|
|
|
Post by David Drake on Feb 12, 2020 6:50:40 GMT -5
What I have enjoyed about this thread is the collaboration. Brandon, tsh73, Rod, and I all participated in the effort. If you count the tips and tricks learned from the previous tiny calculator thread, the contributors expand to include Carl and Chris. Great fun and a nice community spirit. Thanks, everyone, for being such a kind on-line family.
|
|
|
Post by David Drake on Feb 12, 2020 8:50:53 GMT -5
Okay, so I had to look again. - Rod, I added your suggestions, except for the limit checking -- it is needed to keep the "mountains" from going off-screen.
- Improved playability by changing timer to 99ms and slowing "gravity" to .3
- Eliminated the "end" statement (bad practice, but it still works)
- Deleted the "trapclose " statement - good practice but not necessary
- Eliminated a few more CRLFs
- Tweaked a few parameters to improve the layout of the terrain
I think that's all. - Using the LOF() method, the *.bas file is now 977. - Using "cut and paste into word processor" method - 968 characters. Here's the code: nomainwin:r$="BOOM":f=1:prompt "Level 1-4";f:f=min(4,f):WindowWidth=800:WindowHeight=600:open "" for graphics as #1:a$="place 1 11;turn 180;go 10;getbmp ":#1 "when characterInput [k];setfocus;color white;down;fill black;size 2;getbmp b 1 1 800 600;place 1 21;box 21 41;getbmp j 1 1 20 40;size 25;";a$;" m 1 1 5 20;color red;";a$;" n 1 1 5 20;addsprite L j;background b":q=rnd(1)*650:x=10:y=10:i=f:j=f:s=400 while a<800:a=a+4:if a>q+100/f or a<q then s=s+8*f*(1-rnd(1)*2):s=Min(Max(200,s),500):#1 "addsprite M";a;" m;spritexy M";a;" ";a;" ";s else #1 "addsprite N";a;" n;spritexy N";a;" ";a;" ";s end if:wend timer 99,[a]:wait [a] j=j+.3:x=x+i:y=y+j:if x>780 or x<1 or y>580 or y<1 then [b] #1 "spritexy L ";x;" ";y;";drawsprites;spritecollides L d$":if instr(d$,"M") then [b] if instr(d$,"N") then if j>5 or i>3 or i<-3 then r$="OUCH" else r$="Nice!":goto [b] end if:wait [k] k$=Inkey$:j=((k$="=")*(-5))+j:i=((k$="[")*(-1))+(k$="]")+i:wait [b] notice r$:close #1
|
|