03-10-2002, 10:41 AM
Hi, I'm programming my very first side-scrolling game, and already I've run into a problem. It's not a big problem, but I want to know how it would be efficient to load a map/screen. Would I want to do the Levels in sections, and load them when they are needed? Should I generate a DC? I'm not sure of any other methods, but that's why I"m asking.
If anyone needs more details, I'll be glad to draw out everything more, Thanks
03-10-2002, 02:32 PM
If you loaded a screen, you would perhaps need one form for the whole game.
I did mine with a bunch of forms. (42)
So, will this be a game like mine? Controls on the form make the game?
I would imagine that you would load each level when the user completes the previous.
03-10-2002, 02:54 PM
Well, this is going to be a side-scrolling fighting game, but I'm not sure of an efficient way to load maps, that would use as few resources as possible. I never really though of using many forms, because the game form will be somewhat complex, with a life bar, a score bar, and a couple other things, this will also be like an RPG, and will take a little while to beat, so there will be text, so I'll have to include that.
But I'm not sure of a good way to load in the maps, that's my only problem right now.
03-10-2002, 09:12 PM
Are the maps done in lots of little tiles which make up the map or one big bitmap?
If it's one big map, then just load it in at the start, if lots of little tiles, then load them hiding in the main form and draw them onto the screen, either with directdraw or bitblt.
03-10-2002, 09:50 PM
Yeah, I think it's going to be constructed of one large bitmap, though I'm starting to think that I could make it better if I just have everything in a notepad, and then move the tiles forward, scrolling them, not just column by column.
Thanks for your help
03-12-2002, 02:50 PM
Well, I have thought about using tiles, and then loading them in, but would it be practical, (and low on resources), to bitblt a section of the Level from a notepad, then load it whenever I figure out when I'm going to.
But when you use bitblt, does that turn it into a bitmap, also, and uses the same amount of resources as a bitmap?
Let me reword that, If I bitblt a screen to a form, and I use loadpicture, of the SAME picture on another form, will they both use the same amount of resources?
Thanks for your time
03-12-2002, 03:06 PM
BitBlt is a function, so doesn't "load" a bitmap. It will copy a bitmap form one place to another..
The way IMHO is best to do it - draw out your tiles in your fave graphics program, then save them all as once file, lined up nicely, next to each other. Then, place this image into a picturebox on your form.
Whenever you want a tile, you merely have to BitBlt from the picturebox at the right coordinates, using very little resources at all.
I believe BillSoo has posted an example of a tileset.. and it moves as well! Here it is (http://www.visualbasicforum.com/showthread.php?threadid=7965)
03-12-2002, 03:48 PM
All right, well then, using a fair amount of resources, could I just make some kind of thing like that, then have a picutebox, then just bitblt the whole thing in, since it's only a mere copy, which would go light on the resources?
Better yet, I was wondering if it is possibe that I could make it so that when the user moves right or left, I could make the giant bitblt'ed thing scroll, like moving the bitblt'ed picture, is that possible?
03-12-2002, 05:01 PM
The only 'resources' taken up would be your picturebox, depending on how you 'bitblt in' the picture. If you load it into a memory DC, BitBlt it into the picturebox from the memory DC, then clear the memory DC, there'll be a couple of microseconds when you're doubling the amount of 'resources' you use, but this will be negligable. If you're going to set the picture at design time, the only resources would be the memory required to hold the image, nothing special.
Any image manipulation you are doing, will only ever be 'a mere copy'.
You have to create the scoll effect, by moving where you're BitBlting to. Did you look at the link I provided? It demonstrates the scolling perfectly....
03-12-2002, 09:23 PM
Oh yeah, I think I was one of the people whom BillSoo made the map for, along with a few other people, but that's not the kind of scrolling that I want. What I want to do is to get very smooth scrolling, as opposed to moving a large unit, like the 32 pixels that his tiles were made of, so what I think I'm going to do is:
Make a long picturebox, which will contain a *Section* of the level, but the picturebox won't be all that long, but the level will have a few different parts to it. For instance, you might start outside on a street, and then go into a building or something, and I'll pull the picturebox back, and reBitBlt the next part, or I could try to find times where the game is interrupted with text, at which point I could reBitBlt the next part of the level, but I think I"m going to be set, thanks.
BTW: If I do have a long picturebox, about maybe 30 inches in length, and not that high, will that cause lagging in my game?
03-13-2002, 03:39 AM
30 inches? Do you have a monitor that big?! If you dont, then dont have a picturebox so long that you can't see it all. You will only need a picturebox as long as you can see...
Sounds like you're going to move the picturebox instead of whats in it? You could do that I guess... personally though, I find BitBlt to be easily fast enough to provide perfectly smooth scrolling. If you want *really* smooth, then ask Squirm about DirectX, or start looking into using arrays and pointers for low level bitmap read/writes, of which BillSoo has again posted a code sample.
03-13-2002, 07:18 AM
Well, I had intended on making it so that the levels are somewhere about 30 inches long, and I could BitBlt that into the massive picturebox, at which point I would smoothly scroll the picturebox, by moving it a few pixels when the user *walks*. I really don't want to use Direct X for something like this, since it's going to be more or less a simple game. I'm just wondering if the game would lag with a large picturebox like this for the screen
03-13-2002, 07:46 AM
Dont BitBlt more than is necessary, to represent scrolling you would alter the coordinates used in BitBlt call to grab different parts of the picture.
03-13-2002, 09:21 PM
Well, after I BitBlt everything to the picturebox, could I possibly move that massive picture, and scroll the picture around INSIDE the picturebox, or is that not possible? What I want to do is BitBlt the part of the level that the user has gotten to, at which point the giant image will be BitBlted into the picturebox from tiles, and just move the image inside the picturebox left and right, respectivley?
Thanks for your time
03-14-2002, 03:04 AM
Do you have a decent video card?
Something like a tnt2 or better...
If so, you should try and learn DirectDraw and use the video card to handle the graphics, you'll get much more better speed out of it and it will give the cpu a break so it can do other things instead.
With Directdraw, you can setup several screens.
One for the background, where you draw everything and one for the foreground which is what the people will see. The scrolling will be much smoother and also be quicker then bitblt.
03-14-2002, 03:07 PM
Yes, I do have a nice video card (G Force MX2, if that is good), and I *COULD* use DX for it, but I stated eariler that I don't want to use this, since a lot of my friend's machine's aren't quite as fast, and I want this game to be as universal as possible.
Maybe in a while, I'll do DX, but I think bitblt would be good for this. I've been trying to find tutorials on it on the net, but everytime I find something, there's always a file missing...grrr...lol
03-17-2002, 11:31 AM
Okay, would it be efficient, if I loaded the map into a picturebox, and then bitblted the level to the picturebox, and then cleared the picturebox, leaving the copy of the background in the picturebox that I blt'ed to? I think this would be a good way to do it, but are there any suggestions, as to why this might / might not work?
03-18-2002, 07:28 AM
I will try to explain this one more time... It seems we've all got our wires crossed somewhere.
Computer_Guy: BitBlt is fast enough that you dont need to worry about 'resources' or efficiency. You said you were only doing a simple game, because your friends machines weren't very good. In this case, BitBlt will be perfect.
To load maps... if its a tile based game, you would construct a *single* bitmap graphic of all the tiles. Since all the tiles should be the same size, to copy a tile, you need only bitblt a certain section of that box.
You would have two pictureboxes, one to draw in, and one to store your tilemap. Each time you draw a frame, you would clear your main picturebox, and BitBlt tiles into it, from your graphic one.
Don't worry about speed etc, BitBlt is quite capable of this.
To move the map, you BitBlt different tiles, at different coordinates, which you will have to work out.
Of course, thats only one way of doing it. You could move a giant picturebox by its left and top properties, but IMHO, a bit of clever BitBlting is by far the best. If you're still really stuck, I can knock up a simple demo of this technique if you'd like.
03-18-2002, 12:20 PM
All right, well, it did seem that we *both* were misinterpreting the other. The previous post I had made was just a thought, and was wondering if anyone thought that it was a good algorithm. So now what I've figured out is that I'm going to use BitBlt to do this game. Yeah, I think I got my answer for this question though, since I'm almost ready to start doing the game. Thanks everybody :D
PS: I'll have to try to be more clear in the future, to prevent communication problems ;)
03-18-2002, 12:23 PM
But could you whip up a minor example if you had some time? I have one way in my mind, which would be using some BitBlting, but I think a second opinion would be nice.