help with graphics

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
me50

help with graphics

Post by me50 »

help im trying to make an rpg but my graphics are worse than the first pacman can someone tell me how to make a graphics loading program so i can just load my graphics :?:
me50

please

Post by me50 »

Im not asking fro some homework help or anything i program because i want to not because i have to so can you please help me.
Z!re
Veteran
Posts: 887
Joined: Wed Aug 04, 2004 11:15 am

Post by Z!re »

Code: Select all

DEFINT A-Z
TYPE BMPHeaderType
 ID AS STRING * 2
 Size AS LONG
 RSV1 AS INTEGER
 RSV2 AS INTEGER
 offset AS LONG
 HORZ AS LONG
 WID AS LONG
 HEI AS LONG
 PLANES AS INTEGER
 BPP AS INTEGER
 COMPRESSION AS LONG
 IMAGESIZE AS LONG
 xRes AS LONG
 yRes AS LONG
 CLRUSED AS LONG
 CLRIMPORT AS LONG
 Pal AS STRING * 1024
END TYPE
DECLARE SUB LoadBMP (DestSeg%, SegxRes%, SegyRes%, File$, sX%, sY%, SwitchPal%, Trans%)


CLS : SCREEN 13

LoadBMP &HA000, 320, 200, "MyPic.BMP", 0, 0, 1, -1
'&HA000 = Video Segment, the segment of the screen
'320 and 200 is the resolution of the videosegment, in screen 13
'"MyPic.BMP" is just a BMP file, must be 256 color
'0, 0 is the top, left location to start drawing the image from
'1 is if it should change the palette to that in the BMP (0 is no)
'-1 is the color to treat as transperent, -1 means all will be drawn

SUB LoadBMP (DestSeg%, SegxRes%, SegyRes%, File$, sX, sY, SwitchPal%, Trans%)
DIM bmp AS BMPHeaderType
f% = FREEFILE
OPEN File$ FOR BINARY AS #f%
GET #f%, , bmp
IF SwitchPal% THEN
 pall$ = bmp.Pal
 IF LEN(pall$) = 1024 THEN
  OUT &H3C8, 0
  FOR I% = 1 TO 1024 STEP 4
   b% = ASC(MID$(pall$, I%, 1)) \ 4
   g% = ASC(MID$(pall$, I% + 1, 1)) \ 4
   r% = ASC(MID$(pall$, I% + 2, 1)) \ 4
   OUT &H3C9, r%
   OUT &H3C9, g%
   OUT &H3C9, b%
  NEXT I%
 END IF
END IF
Byte$ = SPACE$(bmp.WID)
DEF SEG = DestSeg%
wide% = bmp.WID - 1
Hite% = bmp.HEI - 1
offs& = LOC(f) + 1
FOR y% = Hite% TO 0 STEP -1
 IF sY + y >= 0 AND sY + y < SegyRes THEN
  GET #f%, offs&, Byte$
  FOR x% = 0 TO wide%
   IF sX + x >= 0 AND sX + x < SegxRes THEN
    c% = ASC(MID$(Byte$, x% + 1, 1))
    IF c% <> Trans% THEN
     POKE (sX% + x%) + (sY% + y%) * (SegxRes + 0&), c%
    END IF
   END IF
  NEXT x%
 END IF
 offs& = offs& + bmp.WID
NEXT y%
CLOSE #f
DEF SEG
END SUB
Loads a BMP file, must be 256 color BMP though. And only works in screen 13.

Have fun.




Tip: Learn more programming before you try a RPG. If you can't make all parts of the game yourself, then don't even try to make it. Learn everything yourself first, only then can you ask other people.

Because I'm sure you wont understand anything of the code I posted. And if you do, why did you need me to post it in the first place?.
I have left this dump.
mossy1991
Newbie
Posts: 2
Joined: Sun Jan 16, 2005 12:26 pm

erm...

Post by mossy1991 »

i tried that code with MyPic.bmp in the same folder and it didnt work
what have i done wrong
lurah_

Post by lurah_ »

Run QB.EXE/L
Rattrapmax6
Veteran
Posts: 1055
Joined: Sun Jan 02, 2005 2:11 pm
Location: At my computer
Contact:

Post by Rattrapmax6 »

I don't know much bout BMP loaders, I think BMP r a bit 2 heavy(MB wise), but if your loading into QB, it has to be under 320x200, and also saved under 256colors. If you picture doesn't meet this it wont load... :wink:
-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
Rattrapmax6
Veteran
Posts: 1055
Joined: Sun Jan 02, 2005 2:11 pm
Location: At my computer
Contact:

Post by Rattrapmax6 »

Hay, If you'd like some better graphics, and you know how to use MS Paint(meaning able to under stand pixal shading and mixing). You might like this type of code..

Code: Select all

SCREEN 13
xl = 10: yl = 10
DATA 24,24,00,00,12,12,00,00,24,24
DATA 23,23,14,14,12,12,14,14,23,23
DATA 24,24,14,14,12,12,14,14,24,24
DATA 23,23,14,14,12,12,14,14,23,23
DATA 24,24,14,14,12,12,14,14,24,24
DATA 23,23,14,14,04,04,14,14,23,23
DATA 24,24,14,14,04,04,14,14,24,24
DATA 23,23,14,14,04,04,14,14,23,23
DATA 24,24,14,14,14,14,14,14,24,24
DATA 23,23,00,00,00,00,00,00,23,23
FOR y = 1 TO yl
    FOR x = 1 TO xl
       READ z
       PSET (x, y),z
    NEXT
NEXT

' Moves the picture out of the corner...
DIM scorpian(10 * 10) 'or 100 (10x10)=100
GET (1,1)-(10,10), scorpian
CLS
PUT (160,100), scorpian, PSET

This is somthing like Scorpian in Robo Raider, ofcource I made him with LINE staments, I'd had him done faster this way(and alot better). This code should work so you can copy it, and I'm sure you can see what its doing, if not PM me... Or email, I can prob explain it.. :wink: I'm using this in SpaceWarp, so when ever Pete puts up the next mag, look at the Screens I sent in for it for a better example... Note: I added tracks in his treds to this pic..

you can also look at the x.t.r.GRAPHICS intro to BA-SIC MU-SIC II, that was DATA drawn, 8)

PS: The code above is 10x10, use 20x20 or a lil higher for more texture room. :) It also helps to make a chart of all 256 colors, thats not hard if you know any bout FOR..NEXT, n some other minor codes..
-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
Z!re
Veteran
Posts: 887
Joined: Wed Aug 04, 2004 11:15 am

Post by Z!re »

Using inline data is considered bad coding though, as it uses up valuable code space. And severely limits the size of your code.

External files is the way to go.
I have left this dump.
Rattrapmax6
Veteran
Posts: 1055
Joined: Sun Jan 02, 2005 2:11 pm
Location: At my computer
Contact:

Post by Rattrapmax6 »

Aye, thats y I wanted to know how to BSAVE n BLOAD in another topic. I set up 1 program to generate the DATA pics, N now thanks to (can't spell his username, the 1 with the blue neon grim reaper avatar) BSAVE them to outboard .GFX or I like using .XTR(get it?? never mind lol) and in my main program, BLOAD em in under 6 lines... Due to story line tho, I'm prob still going to have 2 chain SpaceWarp,. :roll: :wink: oh well.

Besides, DATA drawing is no diff than PP256, MS Paint, or other editors, cept you get to see what your drawing while you draw with 'em. :)
-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
Z!re
Veteran
Posts: 887
Joined: Wed Aug 04, 2004 11:15 am

Post by Z!re »

Ah, Nekrophidious or something :P

I just call him Sodapop... although he might kill you for that... :D

The name everyone use when refering to him is either Nek, or Ado
I have left this dump.
Rattrapmax6
Veteran
Posts: 1055
Joined: Sun Jan 02, 2005 2:11 pm
Location: At my computer
Contact:

Post by Rattrapmax6 »

Kill me? If he can find me, and he better bring a gun(dads a x-cop so I know load of self-defence stuff, even takin a gun away from ya)..

Also how I know how to send my Jeep into a sidewinder, anyone want to go for a ride with me in my feild?? :wink: Just don't ride with my dad in the Jeep, he does it faster than me (I try not to flip :lol: ).

I'll just use Nek,. :roll: just to be safe neway :wink: ..
-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
MystikShadows
Veteran
Posts: 703
Joined: Sun Nov 14, 2004 7:36 am
Contact:

Post by MystikShadows »

Well I kinda like sodapop ! LOLOL

* Doesn't run for cover, will fight anyone/anything (thinking grim reaper here) even death till the death (although i'll probably loose that last one ;-).

So SodaPop, still fizzin at your age? I know I am LOL..
When God created light, so too was born, the first Shadow!

MystikShadows

Need hosting? http://www.jc-hosting.net

Interested in Text & ASCII development? Look no further!
http://www.ascii-world.com
Nodtveidt
Veteran
Posts: 826
Joined: Sun Jul 25, 2004 4:24 am
Location: Quebradillas, PR
Contact:

Post by Nodtveidt »

Nah, I'm a pacifist these days. :D That's why I have a young virile and incredibly tough woman to do the dirty work now. :D Hell hath no fury like a pissed off Latina. :D
Post Reply