Sign in to follow this  
civilwarrock

[.net] My Game Maker Help?

Recommended Posts

Ok guys, i have been working on my game maker in vb for a long while now. But it works and i am happy. But i am lacking one feature i need "Blocks" to keep users from walking throught stuff now i have them tackled some what. The way it needs to work is simple. I need to save pictureboxes in a list of pictureboxes into the C:/ drive and then load them back into a list of pictureboxes. I know you can do this using xml. But is there another way. And if you could provide a code that would help a ton. Please Help. Thanks - civil

Share this post


Link to post
Share on other sites
Don't use PictureBoxes, they're extra memory overhead that is completely unnecessary. For whatever object your drawing area is (your window, a panel control), call the CreateGraphics method and use the Graphics.DrawImage method to draw Bitmap objects that you load from BMP, PNG, or whatever image type files with either the Stream or String version of its constructor.

Share this post


Link to post
Share on other sites
Yes, or perhaps even just BitBlt. I used that all the time when I programmed VB.
You can always abstract the geometry into some variables, and avoid pictureboxes.
As Cpt. Midnight said, they are extra memory overhead. I had a 32Mb Pentium machine
back in 2000 which I created a simple crafting game on, inspired by runescape.

It contained around a hundred pictureboxes, and ultimately, not all of the form would load:
The VB Designer would leave out some of the pictures... :/

It's common, good practice to seperate a game into more layers of graphics, business logic and backend storage. (And many, many variants of this.)

Share this post


Link to post
Share on other sites
Guys, i am not using pictureboxes for images. I am using them for the control. For example when i figure out how to save them and load them back in i can use a code to tell if one picturebox hit another. Thats why i am using it. Just as a maker. Thats all. Please help me on how to save and load them. Thanks - civil

Share this post


Link to post
Share on other sites
Could you explain to us how you are creating the maps? Are you using tiles? are the tiles moving on the map? In other words do you need the blocking areas to be moveable too?

Share this post


Link to post
Share on other sites
Still, this
Quote:
Original post by civilwarrock
i can use a code to tell if one picturebox hit another.

sounds a little suspicious.

You don't actually need to use pictureboxes for collision detection.
Do you have one for the bounding box of every sprite?
Maybe I'm just misunderstanding you.

Share this post


Link to post
Share on other sites
Ok guys, well my game maker draws images onto a picturebox witch i use as a map. Then from there i save it and open it up in my game player. The map deos not move at all. But you have the option to put down blocks. Your char witch will be drawn on a form in game play just like the map. Now a emty picturebox follows the char were ever he geos. This is why i need to use pictureboxes so that if my picturebox following the char hits a standing still picturebox i can code a block. This all works ecept for the fact i need to be able to save pictureboxes and load them back in. Thanks - civil

Share this post


Link to post
Share on other sites
Quote:
Original post by SuperVGA
Still, this
Quote:
Original post by civilwarrock
i can use a code to tell if one picturebox hit another.

sounds a little suspicious.

You don't actually need to use pictureboxes for collision detection.
Do you have one for the bounding box of every sprite?
Maybe I'm just misunderstanding you.


Can you please explain this bounding box methed for a sprite? Cause i think that may salve some problems. But how do i save them? - civil

Share this post


Link to post
Share on other sites
Yes, alright.

Ok first thing would be to know how to blit a sprite or other 2d feature
onto your (preferrably doublebuffered) frame.

Secondly, the bounding boxes i mentioned can be used for instance if you have
Type MyBB
left
top
width
height
End Type

You check for overlapping instances of MyBB.

For instance, if the left component one corner of BB1 is higher than left of BB2, but lower than left+width of BB2
AND
the top component of same corner of BB1 is higher than the top of BB2,
but lower than top+height of BB2,
-then there's a collision. (Test for all corners to see if the rectangles overlap)

After that, you could test the masks of the sprites, or alpha values to do pixel-perfect collision test.

Am I making sense to you?

Share this post


Link to post
Share on other sites
Ok my VB is a little rusty, I forgot the types.

Anyway, you know how a Type definition works in VB,
or you could create a Class and be able extend its functionality later.

For now, the type should contain the placement of the sprite,
as well as the dimensions of the sprite. For instance, if you want the
car image in the center of the window, and the car is 128x128, the window
being 800x600:

car_left = (800 - 128) * 0.5
car_top = (600 - 128) * 0.5

You can simply compute to check if two boundaries intersect by testing

car_left and car_right against an x value of the point to test intersection with.
car_top and car_bottom against an y value of the point to test intersection with.

You understand better now?

Share this post


Link to post
Share on other sites
yes, but heres the thing. How can a user create a block border and position it were he needs it and save all the block borders? See a problem right. But if you could or someone else tell me how to save a list of pistureboxes into the C:/ drove and load them back in. I can actually use my code to detect weather a speacial picturebox has hit a block and then code the block from there. This a a advanced program. Maybe a little to advanced. Its a game maker but what surprisses me is that people done nessasarly stop to think maybe they need more than one. I mean the user could create 300 for all i care but as long as it saves and loads back in with the name location and Size and maybe color. I dont care. - civil

Share this post


Link to post
Share on other sites
To be honest I have a hard time understanding what the problem is (and I guess a few others too)
Forgive me for asking the following questions, it is not my intention to make fun of you or doubt your expertise:
1. Do you know how to save data in a file?
2. Do you know how to create multiple instances of a class?
3. Do you know how to put those multiple instances in a list or array?
4. Do you know how to use serialization?

You see, the names you are using to explain your problem are not very common or at least ambiguous. PictureBox is something very particular in VB but my guess is you are using it to refer to a tile. But I might be wrong. Could you post the code that shows us how you are storing your leveldata so far?

Share this post


Link to post
Share on other sites
Quote:
Original post by civilwarrock
i can use a code to tell if one picturebox hit another. Thats why i am using it.


-This is what got me into the collision test mood, but from the first post it seems more like a serialization issue, yes. I believe you should either refine your question or answer the questions ernow put.

Is this problem about storing a continous images, storing information related to form controls such as a Picturebox or both. Also, why would you save Picturebox properties to a file? ...

When I save images, I prefer to RLE compress them, and save them all sequentially into one huge DAT-file. :)

It's easy to implement and easy to handle.

Share this post


Link to post
Share on other sites
@SuperVGA: My guess is he is not using pictureboxes but uses this term to refer to tiles. And perhaps all he needs to know is how to write the tile data (not the images) to a file...

Share this post


Link to post
Share on other sites
Enrow is right, that is exactly what i am trying to do. And no i dont know how to do those things, im only 12 and my game maker rocks. I just want to save a picturebox just the picturebox only no image or color. And then i want to load that back in. - civil

Share this post


Link to post
Share on other sites
You say that Enrow (Ernow) is right, but then you say that
you only want to save the picturebox data to a file.

If ernow is right, you don't want to save the picturebox data to a file,
but the data of the individual tiles. Is this, then about saving other picturebox data such as size and position?


. . . .
. . X X
. . X X
. . X X

-X'es are offset at (2,1), and have the dimensions 2 x 3

Because then i recommend saving the data in a grid structure, where
every tile is followed by the next and thus not needing to store the offsets,
-or sizes for that matter.

I really want to help, I'm just not sure >exactly< what you mean, and I don't want
to confuse you. 12 yrs? That's great, I was 8 when I began, but first moved to windows when I was 14.
But considering that we keep talking about pictureboxes, I still think you are
"crossing the river to get water". It may be easier to do.

Share this post


Link to post
Share on other sites
I am afraid you're aiming a little too high for now. Focus first on the basics of the language such as Classes, Objects and Lists.

If you skip these you will be copying code without understanding it and that will bring you to a halt very soon.

As for being 12, that is no problem, do not worry about that.

Please post your code and I'll have a look.

Share this post


Link to post
Share on other sites
What I suggest you is to learn the basic like ernow said and after you could learn the rest when you'll need to. Also for your case, I suggest you to use the BinaryReader/Writer because if you only need to save 2 types of data (like SuperVGA said ex: "." and "x") you could save booleans.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this