View previous topic - View next topic |
Author |
Message |
Bjorn Demon Hunter
Joined: 29 May 2002 Posts: 1425 Location: Germany
|
Posted: Sun Jan 19, 2003 12:31 am Post subject: |
[quote] |
|
Barok, I'm sorry but I didn't have time to take a look into your engine because of time problems. University projects kicked in. Are you using XOR to draw masked pictures? Here's how we used to do that:
Code: | PUT (X, Y), MaskImage, AND
PUT (X, Y), Image, OR |
If I remember correctly, two colors were used in the MaskImage, color 255 (at which existing pixels would stay the same) and 0 (at which existing pixels become black). Then in the second pass, the black pixels got replaced with the colored pixels in the Image, while the rest would stay the same because the Image would be black there. I was quite proud on this discovery, but I guess Tenshi knows of a better way to do masked images. :-)
Tenshi, I've never been able or wanted to understand the POKE command just because it never seemed clear what some POKE command did. Using the proper variable names and comments helps a lot though. It's pretty cool that double buffering is indeed possible. I had made a study of the format GET/PUT used to store pictures in memory and thought about writing my own PUTPIXEL/GETPIXEL commands to operate on those by manipulating integers. Never really did that because I figured that would be hell slow though. Thinking about it, didn't you forget to set the size of the image in the beginning of the SCRNBUFF array?
BTW, wouldn't QB 7.1 be the more logical choice because it's newer? We never used it because the mouse lib we used in the editor worked only with QB 4.5.
|
|
Back to top |
|
|
Tenshi Everyone's Peachy Lil' Bitch
Joined: 31 May 2002 Posts: 386 Location: Newport News
|
Posted: Sun Jan 19, 2003 7:54 am Post subject: |
[quote] |
|
- The whole Mask AND / OR thing is memory wasteful, I remember doing that way back in the day, too.
Actually, the whole using the color 255 and 0 for mask comes down to bitwise operations.
255 || (8-bit) = 255 so no color is placed
0 || (8-bit) = 8-bit so color is placed.
- QB7.1 *would* be the logical choice, but because most libraries make use of 4.5 , I stayed with 4.5.
- And yes, I do, but keep in mind this is a *BASIC* method. It does not take into account Clipping if the sprite is "offscreen", etc. Those are easy to overcome, but I'm too lazy to code it up. =T
Code: |
SCREEN 13
DIM SCRNBUFF(32002) AS INTEGER
SCRNBUFF(0) = 320 * 8
SCRNBUFF(1) = 200
DIM SPRITE(LENGTH * HEIGHT / 2 + 2) AS INTEGER ' 1 frame sprite
DEF SEG = VARSEG(SPRITE(0))
BLOAD "sprite.spr", 0 ' Load a sprite that's been previously saved.
' Okay, now we have graphical data.
ADDRESS& = 4 + (STARTX + STARTY * 320&) ' Beginning address in buffer
LOOKADDR& = 4 ' Address of sprite to begin looking through
'
' The address begins at 4 because QB stores the length and height attributes in the first 2 integer elements of the array.
' Well.. LENGTH * 8 and HEIGHT, accordingly. So the first pixel begins at address 4 since 0 - 3 are taken. =D
'
FOR Y = 0 TO HEIGHT - 1 ' sprite height
FOR X = 0 TO WIDTH - 1 ' sprite width
DEF SEG = VARSEG(SPRITE(0))
COLOUR = PEEK(LOOKADDR& + X) ' Look up sprite for pixel color
IF COLOUR THEN ' If color isn't black.
DEF SEG = VARSEG(SCRNBUFF(0)) ' Target buffer
POKE ( ADDRESS& + X ), COLOUR ' Insert color at coordinates on screen
END IF
NEXT
ADDRESS& = ADDRESS& + 320 ' width of offscreen buffer
LOOKADDR& = LOOKADDR& + WIDTH ' width of sprite
NEXT
'As you know, the address of any tile stored linearly in memory is Y * WIDTH + X
' 10, 10 = 10 * WIDTH + 10
PUT (0,0), SCRNBUFF(0) ' Put offscreen buffer to screen.
|
- d00t d00t.
- POKE is a command that inserts a byte into a specified location in memory, from the last set variable segment (set by the corresponding DEF SEG).
- PEEK looks up a byte of memory and returns its value. Two very important commands for double-buffering, as I showed above.
Quote: | Thinking about it, didn't you forget to set the size of the image in the beginning of the SCRNBUFF array? |
- Probably. =D _________________ - Jaeda
|
|
Back to top |
|
|
Barok Stephen Hawking
Joined: 26 Nov 2002 Posts: 248 Location: Bushland of Canada
|
Posted: Mon Jan 20, 2003 4:02 am Post subject: |
[quote] |
|
i have a new problem. (what did you expect? presents?)
anyways, i've almost completed my scrolling engine. but there's a problem. when i press left on the map in a certain spot (i think it's in a certain row) it tells me there's a problem when i load up the grass tile. i don't have time to put code (i can't, i'm using school computers. i don't have the code on me.) so i'm gonna hope that someone can help me here while i debug my program.
thanks anyways bjorn. I know what it's like to have no time. this weekend, i had a midget hockey tournament. (in case you're wondering, we came up d side champs (we really played bad. We should of won the whole thing!) i got back sunday, 1:00, and by two, my mum had to pick me up to reff a game that i didn't want to do! I didn't have time to do anything after that, as i have a final exam tommorrow. (only have to write one! woo hoo!) i managed to get the scrolling engine working to some degree, and i managed to reduce flickering by over 90%! but if anyone knows anyplace that has flickering tips or tutorials, just put a link down. _________________ Adosorken: I always liked slutty 10th graders...
Rhiannon: *Slap!*
|
|
Back to top |
|
|
Barok Stephen Hawking
Joined: 26 Nov 2002 Posts: 248 Location: Bushland of Canada
|
Posted: Sun Feb 09, 2003 5:44 am Post subject: |
[quote] |
|
hmmm... is it necessary to use varseg and varptr in pixel scrolling engines? I haven't used it in any of the other four engines i developed... btw, what i meant was that i developed a tile*tile, p*p, p*t, and t*t scrolling. _________________ Adosorken: I always liked slutty 10th graders...
Rhiannon: *Slap!*
|
|
Back to top |
|
|
Tenshi Everyone's Peachy Lil' Bitch
Joined: 31 May 2002 Posts: 386 Location: Newport News
|
Posted: Tue Feb 11, 2003 6:46 am Post subject: |
[quote] |
|
- Yes....
VARSEG & VARPTR return a variable's address in memory... especially d@mn useful in arrays, kind of like a pointer. _________________ - Jaeda
|
|
Back to top |
|
|
lazee barok Guest
|
Posted: Tue Feb 11, 2003 2:44 pm Post subject: |
[quote] |
|
i guess so. the problem is that there are no good varseg and varptr tuts on the net though... at least not from what i can find... i have found scrolling engines without varseg and varptr though...
|
|
Back to top |
|
|
Tenshi Everyone's Peachy Lil' Bitch
Joined: 31 May 2002 Posts: 386 Location: Newport News
|
Posted: Tue Feb 11, 2003 5:27 pm Post subject: |
[quote] |
|
- Check this:
BLOADX VARSEG(PAGE(0)), VARPTR(PAGE(0)), 64004, 0
- Which uses a custom Binary Load function (much, much faster than BLOAD) to load something into memory. VARSEG(PAGE(0)) specifies the VARIABLE SEGMENT to begin loading the data into and VARIABLE POINTER tells it the offset from the VARIABLE SEGMENT to start inserting the data.
- In QB, every variable has a Segment and an Offset. _________________ - Jaeda
|
|
Back to top |
|
|
Barok Stephen Hawking
Joined: 26 Nov 2002 Posts: 248 Location: Bushland of Canada
|
Posted: Wed Feb 12, 2003 1:27 am Post subject: |
[quote] |
|
i found an p*p scrolling tutorial, but it doesn't use varseg and varptr. it's not that bad either. but the viewing window is pretty small though. if you want, i could post the code. it's pretty small. _________________ Adosorken: I always liked slutty 10th graders...
Rhiannon: *Slap!*
|
|
Back to top |
|
|
DarkDread Wraith Lord
Joined: 28 May 2002 Posts: 422 Location: behind your bushes
|
Posted: Thu Feb 13, 2003 9:47 am Post subject: |
[quote] |
|
Okay, so I'm too lazy to read the first 3 pages of this thread... but why not just use a small, but fast graphics lib... like gslib, or something? ...wouldn't that be easier? ...why reinvent the wheel, when someone else already has, you know? _________________ "Goth is a way for ugly people to be interesting."
|
|
Back to top |
|
|
Barok Stephen Hawking
Joined: 26 Nov 2002 Posts: 248 Location: Bushland of Canada
|
Posted: Fri Feb 14, 2003 12:30 am Post subject: |
[quote] |
|
easy way to answer. i am stubborn. i preffer to understand how things work then use them, then use premade stuff. it's just my style. _________________ Adosorken: I always liked slutty 10th graders...
Rhiannon: *Slap!*
|
|
Back to top |
|
|
The Anarchist Slightly Deformed Faerie Princess
Joined: 13 Feb 2003 Posts: 32 Location: London, England
|
Posted: Fri Feb 14, 2003 9:30 am Post subject: |
[quote] |
|
Heh, darkdread, champion of Gslib. I should be thankful though, without gslib my games would be pretty useless. There used to be a bit of controvesy before, as I recall, about libs being 'cheeting' in some way... now everyone uses them. They requre about half the code too, in some cases. If you're intent on it though, why not start from the bottom, make a simple t*t engine, they're the base for most other engines as well. From there work up to t*p, and then p*p. That way it'll be easier. Worry about buffering later, but most of theis code you could basically run on its own without much modification. _________________ Some may know me as MidnightDreamer... time for a namechange.
blackgc.f2g.net
|
|
Back to top |
|
|
Barok Stephen Hawking
Joined: 26 Nov 2002 Posts: 248 Location: Bushland of Canada
|
Posted: Sat Feb 15, 2003 2:49 am Post subject: |
[quote] |
|
i have already made all the types of engine, except t*p scrolling and p*p scrolling. _________________ Adosorken: I always liked slutty 10th graders...
Rhiannon: *Slap!*
|
|
Back to top |
|
|
Guest
|
Posted: Sun Feb 23, 2003 8:59 pm Post subject: |
[quote] |
|
Barok & Bjorn, try looking in the ENGINE section of RPG TYPES,
there you'll find a QB RPG engine, TileXTile QB Engine. Right now it only supports tileXtile movement, but in the next update will include pixelXtile, and maybe even pixelXpixel movement.
Also, included in the .zip download is a pure QB4.5
graphics library, QFX (including SOURCE! -> qfx.bas)
This library contains graphical routines including, custom GET/PUT routines which have multiple frame support, clipping, transparency,
blending, and other little tricks. Currently QFX, is in its fourth beta stage, but QFX BETA 5 will be out shortly and will be used for QB TILExTILE Engine's next release, titled... ESengine.
(ESengine Beta 1 will be available for D/L on RPGDX probably around
mid-april, or sooner.)
Nem
P.S... I'm also looking into a new, GET/PUT routine which will blit and manipulate bits at the integer level (using my quick QB bitops routines.), instead of the byte level, like POKE & PEEK.
|
|
Back to top |
|
|
Bjorn Demon Hunter
Joined: 29 May 2002 Posts: 1425 Location: Germany
|
Posted: Sun Feb 23, 2003 9:17 pm Post subject: |
[quote] |
|
Sounds really cool Nem. And I assume because it's pure QB, it'll work in WinXP too? I should note though that I have given up on QB programming about 4 years ago, I was just trying to help Barok with what I remember.
|
|
Back to top |
|
|
Nemesis Pretty, Pretty Fairy Princess
Joined: 29 May 2002 Posts: 5 Location: N.C
|
Posted: Thu Feb 27, 2003 7:03 am Post subject: |
[quote] |
|
<<Sounds really cool Nem. And I assume because it's pure QB, it'll work in WinXP too?>>
I tested it in DOS, Win3.1, Win 95,& 98, Win XP, and Win 2000.
All OS's ran the libray, and Engine just fine. (I don't know about the other OS's though :(
<
about 4 years ago>>
Too bad. Even some of the best coders I know online still use QB, (once in a while). You should give it another shot. In my case, I have about 6+ yrs. of QB experience.
(I'm pretty much a QB master.)
So, since I'm capable of doing all I want with my games, or programs, with QB, (maybe even pure QB), then why should I use anything else?
(Please Don't answer that :)
>>I was just trying to help Barok with what I remember.<<
Yeah, that's cool Bjorn. I don't even really remember why I mntioned you in the first place? Oh well...
I guess I figured I'd point you all to the D/L, incase you wanted to check out the source code.
Nem
P.s..
My whole purpose (mainly), of turning my computer on, or getting online is because of indie RPG/Game programming and development.
Oh, and because of here too!
So thanx, Bjorn, Mandrake, and all who participate, RPGDX :)
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|