Weekly Qbasic and Qb64 Lesson Topics
October 12, 2024, 06:02:49 pm
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Want to see a specific Tutorial? ASK!
 
  Home Help Search Arcade Links Staff List Login Register  

A Bunny DATA bit map image

Pages: [1]
  Print  
Author Topic: A Bunny DATA bit map image  (Read 251 times)
GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« on: January 30, 2011, 02:14:01 am »

For me this was not that easy to do. But it is interesting, simpley by butting numbers in a data map, one can create a image,..
Quote

'moving the bunny back and forth:
limitfps% = 32
bunnymaxsp% = 100 * limitfps% '*pixels/sec
bunnydirection% = 1
bunnyspeed% = bunnymaxsp% / limitfps%
BunnyWidth% = 16
BunnyHeight% = 16
SCREEN 13
OUT &H3C8, 0
OUT &H3C9, 0
OUT &H3C9, 48

_FULLSCREEN
CLS

' Bitmap for the sprite
DATA 0,0,0,0,0,15,0,0,0,0,15,0,0,0,0,0,0
DATA 0,0,0,0,0,15,15,0,0,15,15,0,0,0,0,0,0
DATA 0,0,0,0,0,0,15,0,0,0,15,0,0,0,0,0,0
DATA 0,0,0,0,0,0,0,15,15,15,0,0,0,0,0,0,0
DATA 0,0,0,0,0,0,0,15,15,15,0,0,0,0,0,0,0
DATA 0,0,0,0,0,0,15,0,15,0,15,0,0,0,0,0,0
DATA 0,0,0,0,0,0,15,15,15,15,15,0,0,0,0,0,0
DATA 0,0,0,0,0,0,0,15,15,15,15,0,0,0,0,0,0
DATA 0,0,0,0,0,0,0,0,15,15,15,0,0,0,0,0,0,0
DATA 0,0,0,0,0,0,0,15,15,15,15,15,0,0,0,0,0
DATA 0,0,0,0,0,0,15,15,15,15,15,15,0,0,0,0,0
DATA 0,0,0,0,0,15,0,15,15,15,15,0,15,0,0,0,0
DATA 0,0,0,0,0,0,0,0,15,15,15,15,0,0,0,0,0
DATA 0,0,0,0,0,0,15,15,0,0,0,0,15,15,0,0,0
DATA 0,0,0,15,15,15,0,0,0,0,0,0,15,15,15,0
DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0

' An array to hold the sprite
DIM Bunny%(BunnyWidth%, BunnyHeight%)

' Read the sprite in from DATA to the array
FOR Y = 0 TO BunnyHeight%
    FOR X = 0 TO BunnyWidth%
        READ Bunny%(X, Y)
    NEXT X
NEXT Y
bunnystart# = TIMER(.001)
bunnydirection% = 1
BunnyStartx% = 0
dothisstuff% = 1
DO
    DO
    LOOP UNTIL _MOUSEINPUT = 0
    SELECT CASE INKEY$
        CASE CHR$(27)
            dothisstuff% = 0
    END SELECT
    IF dothisstuff% THEN
        CLS
        '* your mouse and key handling here
        IF bunnypositionx% >= _WIDTH(0) - BunnyWidth% THEN '* BunnyWidth% is width of bunny image
            bunnydirection% = -bunnydirection%
            BunnyStartx% = bunnypositionx% - 1
            bunnystart# = TIMER(.001)
        ELSEIF bunnypositionx% < 0 THEN
            bunnydirection% = -bunnydirection%
            BunnyStartx% = bunnypositionx% + 1
            bunnystart# = TIMER(.001)
        END IF
        bunnypositionx% = BunnyStartx% + bunnydirection% * bunnyspeed% * (TIMER(.001) - bunnystart#)
        PUT2 Bunny%(), BunnyWidth%, BunnyHeight%, bunnypositionx%, 170
        _DISPLAY
        _LIMIT limitfps%
    ELSE
        EXIT DO
    END IF
LOOP

SUB PUT2 (Sprite() AS INTEGER, XSize AS INTEGER, YSize AS INTEGER, X AS INTEGER, Y AS INTEGER)
' Draw the sprite from the array onto the screen
FOR YP = 0 TO YSize - 1
    FOR XP = 0 TO XSize - 1
        PSET (X + XP, Y + YP), Sprite(XP, YP)
    NEXT XP
NEXT YP
END SUB




'--------------------------------------------------------------------------------



Then Code Guy from the qb64.net gave me the code to make it move.
 from Garry
Report Spam   Logged

Share on Facebook Share on Twitter


Pages: [1]
  Print  
 
Jump to:  

Powered by EzPortal
Bookmark this site! | Upgrade This Forum
SMF For Free - Create your own Forum


Powered by SMF | SMF © 2016, Simple Machines
Privacy Policy