Why Cripple Your New Program?

by Welopez

Okay, you've finished your new Whiz-Bang program and want to "snazz-it-up" a little with some really cool graphics. Is it really necessary that you include full-screen BMP images? On a 1024 by 768 screen, with 24 bit color depth, each full-screen BMP will be about 2.25 MB! If you're trying to simulate animation, with eight, ten, or twelve images, SHEESH! You've got nearly 30 MB of images before you add your BAS code and SLL, DLL files to create an executable!

You can reduce the file size of your BMP images by selecting 265 or 16 colors, instead of Hi-Color or Tru-Color, but huge image files are still huge image files! The beginning creator of web pages likes to add dozens of cool effects. Apparently the same is true of beginning coders. Just because you can do something with Just BASIC, doesn't mean your cool program will be cooler when you do.

Okay, working with your program on your computer doesn't take all day... though you may see a momentary pause while loading or printing images, even if your CPU is capable of speeds measured in giga-hertz. Consider however, your end user who may have a cable or DSL connection. Many will be loathe to download a 30 MB file just to see your really cool program! If your end user has a dialup... forget it! You've just caused him/her to decide it's not worth spending an hour or two (perhaps much more!) just to see your program. Web creators know a user will click off and surf to another web page if their page takes forever to download, and you should be just as smart when you create an application.

Consider creating a BMP "on the fly" using graphic code to GETBMP and DRAWBMP. You can easily fill the entire monitor with only one or two KB of graphic code, including animated displays! This code (written some time ago when I was new to JB/LB) is only 2KB! There are coders in this group who are much more gifted with graphics code than I am, so give it a try and see what you can do!


'Animation Without Image
'Written by Welo, 121904

NOMAINWIN

WindowWidth=500
WindowHeight=500
UpperLeftX=int((DisplayWidth-WindowWidth)/2)
UpperLeftY=int((DisplayHeight-WindowHeight)/2)

button #g.button, "END", [quit], UL, 225, 50, 45, 30

open "Jack-Pump" for graphics_nsb as #g
print #g, "trapclose [quit]"

flag=-5 'flag for "UP" or "DOWN"
x=100 'top of stroke.
y=200 'bottom of stroke

'draw static elements
print #g, "down"
print #g, "fill buttonface"
print #g, "size 10" 'sets line thickness.
print #g, "backcolor black"
print #g, "place 250 150" 'move the pen.
print #g, "piefilled 550 590 85 10" 'draw the jack.
print #g, "backcolor brown" 'new color for the base.
print #g, "place 50 450" 'move the pen to new location.
print #g, "boxfilled 300 500" 'draw the base.
print #g, "flush"

[animate] 'begin the animation.
'remove previous lines
print #g, "discard" 'free memory
print #g, "color buttonface" 'use backgroundcolor to erase objects
print #g, "line 400 "; x ;" 400 "; x-flag 'draw line1.
print #g, "line 100 "; y ;" 100 "; y+flag 'draw line2.
print #g, "line 100 "; y+8;" 400 "; x+8 'draw line4.
print #g, "line 100 "; y-8;" 400 "; x-8 'draw line5.
print #g, "color black"

x=x-flag : y=y+flag 'move the pump rod.
if x=200 or x=100 then flag=-1*flag 'reset flag at bottom or top of stroke.

print #g, "place 100 350" 'move the pen.
'ready to draw.

print #g, "backcolor darkgray" 'set color for flywheel.
print #g, "circlefilled 80 80"
print #g, "backcolor blue" 'set color for counterbalance.
print #g, "piefilled 120 120 "; L ;" 90" 'L sets the angle.
print #g, "line 400 "; x ;" 400 500" 'draw line1.
print #g, "line 100 "; y ;" 100 270" 'draw line2.
print #g, "line 100 "; y ;" 400 "; x 'draw line3.
print #g, "line 100 "; y+8;" 400 "; x+8 'draw line4.
print #g, "line 100 "; y-8;" 400 "; x-8 'draw line5.

TIMER 100, [resume]
wait
[resume]
TIMER 0

L=L+10 'adds 10° to angle L

GOTO [animate]
WAIT

[quit]
close #g
END

With a little creativity, you can use graphics code to display simple shapes such as butterflies, caterpillars, snakes, bouncing balls, etc, and still maintain a small file. Think about having several letters for the title or credits of your program, using different fonts and colors, moving around the screen until they form the words you want to display. One of the nice features of a WINDOW FOR GRAPHICS is you can change positions, colors, and fonts, of words and letters "on the fly!"

If you want people to try your program, don't cripple it by adding tons and tons of MB just because you can. People will be much more impressed with your talents as a programmer, if you show them what can be done with just a few dozen lines, or a few KB, of code.