# Mintoris Forum

### Author Topic: Bitmap Array Demo  (Read 2669 times)

#### Chuck

• Global Moderator
• Hero Member
•     • • Posts: 1899 ##### Bitmap Array Demo
« on: Sep 22, 2012, 01:09 AM »
Here is the program I wrote to test arrays of bitmaps. This program requires Basic 5.5 or higher.

The velocity vectors vx() and vy() are in pixels per second.

Code: [Select]
`' Bitmap Array Demo' Written by: Charles Charbonneau' 9/21/12Graphics OnWakelock OnmaxSprites = 9dim bitmap(maxSprites)dim x(maxSprites)dim y(maxSprites)dim vx(maxSprites)dim vy(maxSprites)maxX = ScreenX()maxY = ScreenY()For i = 0 to maxSprites  bitmap(i) = MakeBitmap(i)  x(i) = Rnd(maxX)  y(i) = Rnd(maxY)  vx(i) = Rnd(500)-250  vy(i) = Rnd(500)-250NextlastTime = Time()Color 0,0,0Do  timeDiff = (Time() - lastTime) / 1000  lastTime = Time()  CLS  For i = 0 to maxSprites    x(i) = x(i) + vx(i) * timeDiff    y(i) = y(i) + vy(i) * timeDiff    if x(i) < 0 then      x(i) = 0      vx(i) = vx(i) * -1    endif    if x(i) > maxX then      x(i) = maxX      vx(i) = vx(i) * -1    endif    if y(i) < 0 then      y(i) = 0      vy(i) = vy(i) * -1    endif    if y(i) > maxY then      y(i) = maxY      vy(i) = vy(i) * -1    endif    DrawBitmap bitmap(i), x(i), y(i)  Next  Touch x,y, 20Loop While x = -1 and y = -1ExitSub MakeBitmap(digit)  bitmap = CreateBitmap(100,100)  SetDrawingSurface bitmap  color 100,0,0  line 0,0,99,99  line 0,99,99,0  TextAlign 0  TextSize 50  d\$ = Str\$(digit)  h = GetTextHeight(d\$)  DrawText d\$, 50, 50 + h/2, 0  SetDrawingSurface Off  return bitmapEnd Sub`
« Last Edit: Jan 23, 2016, 09:03 PM by Chuck »

#### harold ##### Re: Bitmap Array Demo
« Reply #1 on: Sep 22, 2012, 05:54 PM »
Hello Chuck, too deep for me, I'll just enjoy viewing it once in awhile, Harold.

#### Chuck

• Global Moderator
• Hero Member
•     • • Posts: 1899 ##### Re: Bitmap Array Demo
« Reply #2 on: Sep 24, 2012, 03:23 AM »
Try increasing the maxSprites value and see what happens.
« Last Edit: Sep 24, 2012, 03:29 AM by Chuck »

#### harold ##### Re: Bitmap Array Demo
« Reply #3 on: Sep 24, 2012, 04:26 AM »
Hello Chuck, I increased it to 20, that's neat, Harold.