Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating an RPG engine (NEED LOTS OF HELP)

Status
Not open for further replies.

JoQ13

Programmer
Dec 3, 2003
4
US
Ok, I am somewhat of a Q-B New-B, but I have an idea of what I am aiming for in my RPG.

1) TILE ENGINE

I want to create a screen 13 pixil-by-pixil tile engine that uses as much of the screen as possible w/o flicker. This is probly my biggest issue.

I found a very nice example that poked tiles to the screen but would flicker if the window i scrolled in was bigger than 100x80 pixils. I also could not find a way to PUT or POKE a tansparent sprite on the map without a ton of flicker. But it was cool to see it smoothly scroll a 180x180 map in that tiny 100x80 window.

If I could I would like to make it full screen, but I don't want to sacrifice speed for memory (ie. Blast! asm pset routine). I have so many ambitious plans that I am afraid of using up all the memory just for screen buffers and have none left for maps, tiles and specialFX.

One idea I had, but suppose wouldn't work, is to read tiles directly from a file to the blast asm buffer to conserve memory. I thought of this when I realized that a bitmap loader I made that used the blast library could load 4 320x200 bitmaps and their palettes in one second including the time for the blast page copy. Is that fast enough if the tiles are stored in a file and can be read and put in the blast buffer just like the tiles in the memory? Or could that work with the map?

I would rather do away with a buffer all together, but have yet to see a good example of a flicker free unbuffered full screen tile engine that scrolled pix-by-pix.

Please help me with the tile engine, I am dying to start this RPG, but can't unless I have a tile engine that works. I will be more than greatful to anyone who can give me tips and pointers.

2) KEYBOARD ROUTINE

Another problem I had is with the keyboard. I use INKEY$ because its easy, but I HATE the delay when you press the key for the first time. I also hate the beeping when I hold the key down too long. I don't know much about how this keyboard stuff works, but all of the examples using INP(96) suck even more than INKEY$.

The only good keyboard program I found used ASM. It had a little circle that bounced around the screen (I think its called Z-Keys or Multikeys) but It was way too fast and it made the screen flicker AND it got really weird after the program ended and started selecting the text.

I would definitly like some pointers on eliminating the beeping and the delay so if you can, please post your suggestions.

3) SOUND

This is one area in which I am totally clueless. I've sifted through a half a million examples, but all of them either don't work or play really poorly.

All I want is to be able to play midi music and if possible wav sound effects. If I could only loop a midi without slowing down the program that would make my crappy games soo much better. I definitly think that sound is an important part of a game.

I have found programs that play wavs, but it sounded like garbage. I found another program to play some odd "midi-like" music format, but it too sounded like crap and I didn't know where to find music in the format.

Personally I prefer midis because they sound like classic video game music and (I think) they are smaller and easier to read than wavs. But I also want sound effects so if possible I want to use both types simaltaniously(sp?).

4) OTHER IDEAS

I have so many ideas, too bad I can't just put my ideas into the head of someone with the knowhow to program them. Here are some other features I would like to incorporate:

a)
I really want to reserve part of my palette specifically for rotation. Just like in sim city 2000, the building designer palette had flashing colors (for blinking lights, water, fire). If certain colors could constantly cycle w/o slowing down the program, I could add color animation to water and fire without touching a pixil and only using a small part of the palette. Can this be done? That would be awsome to have plasma effects in a tile engine.

b)
I'm also interested in translucency, but I'm not too familiar with how it works. I know you can PEEK at colors and then use an equation to find how bright it is. Then you put the pixils down in one shade of color. This would be cool for poping up menus without obstructing your view, however I wonder if it will be too slow to work while animating. I found a prog called POP13 that uses ASM. I will begin tinkering with it until I understand better.

c)
I also like the way Zelda does not have RPG battles, but instead has real-time fighting. This may be going overboard, since I want pix-by-pix scrolling, but it would be cool. I found one impressie QB zelda clone, but no source code. In general, I need help with incorporating AI characters that would walk around towns and talk to you. Would it be too complicated with PxP scrolling? Please give feedback!

I have SO many ideas for RPGs, I just need a game engine that can at least do PxP scrolling and sound FX. If sombody could at least help me with that I'd definitly put your name in the credits of my game(s). ThanX!




 
I'm working on an rpg too. For personally I would go with DS4QB because of its minimal system requirements (all you need is windows which basically everyone has). As for midis I do agree with you as they do sound more like the old video games, but its way too hard to read them. I've been trying to get into C++ so that I can use Windows API functions to play midi files, but that we'll take awhile. The way all the old systems played music were in channels (i think but i'm not sure). Each channel played a different sound and they were all played at once too make up the music. I think thats why the games were able to have so much music with so little memory. Its easy to change the palette for animation (but not reccommended since it could mess up other colors). Just use:

OUT &H3C8, colortochange
OUT &H3C9, redvalue
OUT &H3C9, greenvalue
OUT &H3C9, bluevalue

that would change the 1 color you specify to the 3 mixed colors red, green, and blue (each color can be 0 to 63. That technique is so faast that it can be used for plasma, fading in/out. Now you could change the palette back to normal using the PALETTE command with no argument, but since I am morally against the PALETTE command (not really tho) you could just save all the RGB values of each color in an array (if you don't know what an array is just ask since I don't know how advanced you are since you did you were a newbie). To read the red, green , and blue values in a clolor just:

OUT &H3C7, colortoread
OUT &H3C9, redvalue
OUT &H3C9, greenvalue
OUT &H3C9, bluevalue

And as for your other questions......well I answer them later cause I'm tired of typing and I want to go play video games. :)
 
Don't count out an offscreen buffer just because you are afraid of memory problems. I have an fullscreen buffer, 19 different 64x64 pixil tiles, multiple high resolution sprites, a wav/movie player, and multiple trig tables and I haven't had any problems with memory.

I wrote an FAQ with gives a flawless multikey routine, take a look at it, it is farily simple, and doesn't pause before repeating.

If you look a few posts back you will see a post called SOUND I think. I wrote out a really good wav player. Its works great on all computers that I have tried it one, inlcuding ones with Windows XP.
 
thread314-713214 : The wav player
faq314-4291 : The keyboard routine
 
and i as well. (making an rpg i mean :p) check out minirpg by relsoft. it's a beauty rpg engine.

i agree with qbasicking. on my engine, i have a buffer, a sprite array (holds up to a thousand tiles) map array, so on and so on and have no problems as well. and if you have problems, there's always ems and xms.

to joQ13: (q/a)

welcome joq13!! you seem very hyped about your rpg, and that's good! we don't get very many games nowadays, as the hype of qb ended years ago. it'll be nice to get a new qb game. one piece of advice it to not aim very high. many people did that, and ended up abandoning their game. they thought they were "different" as well. they thought they would finish their games, but over time, it got too difficult or their hype left them. so be careful.


next, try going to rpg-dev. it's a site for rpg development. it's been sluggish lately, and they'd appreciate a new person. try qbasicnews.com as well. it'ss got lots of people: very busy. Tek tips is very nice, but sadly people come and go. very few people come here regularily. Just me, cube, and qbasicking.

anyways, here's question and answers.

(q)I want to create a screen 13 pixil-by-pixil tile engine that uses as much of the screen as possible w/o flicker. This is probly my biggest issue.

(a)use a buffer, and make your own put routine.

(q)I found a very nice example that poked tiles to the screen but would flicker if the window i scrolled in was bigger than 100x80 pixils. I also could not find a way to PUT or POKE a tansparent sprite on the map without a ton of flicker. But it was cool to see it smoothly scroll a 180x180 map in that tiny 100x80 window.

(a)what is the example program? then we can help you there.

(q)If I could I would like to make it full screen, but I don't want to sacrifice speed for memory (ie. Blast! asm pset routine). I have so many ambitious plans that I am afraid of using up all the memory just for screen buffers and have none left for maps, tiles and specialFX.

(a)don't worry. if you have problems with memory after, consider ems and xms. buffers take very little memory. i only use one. it's all you need.

(q)One idea I had, but suppose wouldn't work, is to read tiles directly from a file to the blast asm buffer to conserve memory. I thought of this when I realized that a bitmap loader I made that used the blast library could load 4 320x200 bitmaps and their palettes in one second including the time for the blast page copy. Is that fast enough if the tiles are stored in a file and can be read and put in the blast buffer just like the tiles in the memory? Or could that work with the map?

(a)you use bitmaps? i prefer to use a program called pp256. made for making tiles, works very nicely. loads tiles up to 100x100. prefer that, as tiles don't take up as much memory. oh, and an interesting idea you have. too slow though. don't worry about memory! just load your tiles the usual way, and scroll the usual way.

(q)I would rather do away with a buffer all together, but have yet to see a good example of a flicker free unbuffered full screen tile engine that scrolled pix-by-pix.

(a)there are lots. i made an archive of pixel scrollers, and only two use buffers. but USE BUFFERS!!! it's by far the best thing to do.

(q)Please help me with the tile engine, I am dying to start this RPG, but can't unless I have a tile engine that works. I will be more than greatful to anyone who can give me tips and pointers.

(a)first of all, start with a tile by tile scrolling engine. once you understand that, work your way to p*p. oh, and download my archive. start with scroll.txt and scroll.bas. it's a pixel scrolling tutorial. very useful for beginners. simple, but not very fast. then try 1pscrll.bas. from there, go wherever. hope that helps.

(q)The only good keyboard program I found used ASM. It had a little circle that bounced around the screen (I think its called Z-Keys or Multikeys) but It was way too fast and it made the screen flicker AND it got really weird after the program ended and started selecting the text.

(a)look for eric carr's multikey routine, and sjzero's. best pure qb multikey routines around. also tell you how to get rid of annoying beep.

(q)This is one area in which I am totally clueless. I've sifted through a half a million examples, but all of them either don't work or play really poorly.

(a)All I want is to be able to play midi music and if possible wav sound effects. If I could only loop a midi without slowing down the program that would make my crappy games soo much better. I definitly think that sound is an important part of a game.

(q)I have found programs that play wavs, but it sounded like garbage. I found another program to play some odd "midi-like" music format, but it too sounded like crap and I didn't know where to find music in the format.

Personally I prefer midis because they sound like classic video game music and (I think) they are smaller and easier to read than wavs. But I also want sound effects so if possible I want to use both types simaltaniously(sp?).

(a)okay, try dmaplay by toshi. best wave player, but doesn't work with my computer. far as i can tell, you can't loop wave files. you need to use a library like qmidi, sbmidi, ds4qb, ds4qb2, ds4qb++ to play midis.

(q)I really want to reserve part of my palette specifically for rotation. Just like in sim city 2000, the building designer palette had flashing colors (for blinking lights, water, fire). If certain colors could constantly cycle w/o slowing down the program, I could add color animation to water and fire without touching a pixil and only using a small part of the palette. Can this be done? That would be awsome to have plasma effects in a tile engine.

(a)can do! palette routines can be easily implemented in qb. unfortunately, that's my weakest area. i'd talk to someone like relsoft. he's very good with palettes (and everything else!) download relgfx. it's a very nice example of qb graphics routines. especially palette routines. oh, if you PUT your buffer with pset, then with, say or, or xor, or something, your buffer will be put differently, creating effects you want.


(q)I'm also interested in translucency, but I'm not too familiar with how it works. I know you can PEEK at colors and then use an equation to find how bright it is. Then you put the pixils down in one shade of color. This would be cool for poping up menus without obstructing your view, however I wonder if it will be too slow to work while animating. I found a prog called POP13 that uses ASM. I will begin tinkering with it until I understand better.

(a)once again one word: relgfx!!!! check out relspriteT. draws a sprite translucently.

(q)I also like the way Zelda does not have RPG battles, but instead has real-time fighting. This may be going overboard, since I want pix-by-pix scrolling, but it would be cool. I found one impressie QB zelda clone, but no source code. In general, I need help with incorporating AI characters that would walk around towns and talk to you. Would it be too complicated with PxP scrolling? Please give feedback!

(a)oh no! that's not overboard! in fact, that's what type of game i'm making. check out ziel. it is what you want. first of all, use multiple sprites when attacking: one for the attacking player, one for the weapon. this allows you to have long weapons without being restricted to a 20*20 sprite, and ending up having a weapon 3 pixels long. second, you'll need pixel perfect collision. i'll talk about ai later, as it's very complicated.






btw, what examples are you guys talking about?
 
I agree 100% with everything that Barok said. Especially the part about not setting your hopes too high. Qbasic is not designed for gameing, and actually it doesn't seem to be designed specifically for anything, but it is a very weak language comparitivly speaking.
 
Thanx QBasicKing/Barok/Kenshinhimura,

I didn't xspect so much feedback so soon. I have signed up at RPG-DEV and I found some really good examples including Ziel (Impressive!). I'm very excited about this project, but I will do my best to supress my excitement before I wear out my enthusiasm as I have before.

I have some source from various repgdev downloads that I will begin picking through for ideas. I suppose that because I don't know any asm i'll have to use that code blindly, but for everything else i'm obsessive about knowing how it works before I use it. I will check out those wav players and keyboard routines (thanx QBking).

I am so happy that there are still other QB enthusiest out there. it's a great language even though its a bit past it's prime.

I have been using it since my brother tought me how to print text to the screen when I was 12 years old. As I'd learn new techniques I'd think of ways to use them and begin a really ambitious project only to lose interest after spending weeks working on it. Then I'd take a break for a few months and sort of have to re-learn what I forgot. But each time I accumulated a little more QB knowledge.

Now I want to make something and actually finish it, so I have somthing to show for the thousands of hours I've spent tinkering with code.

Thanks all of you for pointing me in the right direction. I'll keep coming back when I get stuck on somthing, and hopfully get a working demo of what I'm dreaming up, so I can share my crazy ideas with you guys.

By the way, would it be possible to play a looping wav song and a wav sound effect at the same time?

Thanks!
 
Load the wav sound effect into an array, (just the sound, none of the headers.)

DIM snds(10) AS STRING * 30

SUB soundeffect (a%)
FOR i = 1 TO 15
OUT &H388, ASC(MID$(snds(a%), (i * 2) - 1, 1))
OUT &H389, ASC(MID$(snds(a%), (i * 2)))
NEXT i

This will temporarily stop the wav music from the loop and play the sound effect. STRING * 30 makes it short enough that you don't even notice the change in the loop
 
ah.


well, on my rpg, i've got the sprite blitter and scrolling engine up, but it's so slow! it blits a 20x20 sprite in .05 seconds, but it's nowhere near fast enough. here's the code.

Sub bsprite (x,y,sprite(),frame,mainindex())

'x and y is the coords on the screen. this prog works only with pp256 tiles, btw. sprite holds the tiles, mainindex is a tile index, and frame is which tile to draw.in order to work, this needs a ylut&(199) which goes like this

'dim ylut&(199)
'for x = 0 to 199
'ylut&(x) = x * 320&
'next

If frame = 0 then goto sk

Spriteseg = varseg(sprite(mainindex(frame)))
Spriteoff = varptr(sprite(mainindex(frame)+2))

Spritewidth = sprite(mainindex(frame)) /8
Spriteheight = sprite(mainindex(frame)+ 1)

If x < 0 then
Swidth1 = - x: swidth2 = spritewidth
Elseif x > scrnwidth – spritewidth then swidth2 = 320 – x: swidth1 = 0
Else
Swidth2 = spritewidth
Endif

If y < 0 then
Sheight1 = not y: sheight2 = spriteheight
Elseif y > scrnheight – spriteheight then sheight2 = 200 – y: sheight1 = 0
Else
Sheight2 = spriteheight
Endif

Redim colorlut(swidth1 to swidth2)

Yarray = sheight1 * spritewidth

For yy = sheight1 to sheight2 – 1

Def seg = spriteseg

Yyy = yy + y
Mainoff& = ylut&(yyy) + buffoff

For xx = swidth1 to swidth2 – 1

Colorlut(xx) = peek(spriteoff + yarray + xx)

Next

Def seg = buffseg

For xx = swidth1 to swidth2 – 1

If colorlut(xx) then

Xxx = xx + x
Poke mainoff& + xxx, colorlut(xx)

Endif
Next
Yarray = yarray + spritewidth
Next
Def seg
Sk:


any optimization suggestions? any suggestions is apprectiated, as i'm starting to tire of this.


 
Arrg! I just got done writing my adapted ASM pixil scroller and its slower than the original POKE scroller! The ASM routine is the one from the Blast library. It was supposed to scroll a full screen map one pixl per keypress. All I get is slow scrolling while my keyboard beeps at me.

The code for the scrolling is pretty good when used with POKE, just not fast enough for full screen. But even IT was faster than the ASM scroller. What do I do now?

On the positive side, it didn't flicker and I was able to put a transparent sprite on the map.

Why does this program hate me?
 
One thing I forgot to mention is that I am using the Blast pset routine. Now I'm wondering if the Blast Put routine would be faster. It seemed to me that it wasn't much faster, but I guess I could be wrong. Well, i'll try that now... Gee, I think I just answered my own question! Well, Thanks JOQ13!

Okay, here's one thing I will ask:

Do I really need 2 screen buffers if I use both the Blast put and Plast pset?
 
if you're talking about BLAST pset...

no. they should both work on the same buffer.

does anyone know where i can find a pure qb sprite blitter? (or two) i'm always trying to learn, and i want to see if there's a couple tricks i can learn on sprite blitting. apparently blitting a 20*20 sprite in .05 secs is too slow ;) so i want to see if i can speed it up as much as i can, and any source code would be great.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top