Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Question about 2d games

Author
Message
Jcamden
13
Years of Service
User Offline
Joined: 5th Oct 2011
Location: Washington
Posted: 5th Oct 2011 20:45
Let's say you had a 640x480 screen. Would you create the map and just load different portions of the map based on player movement? To me this method sounds like it would be a HUGE memory hog and would make the game enormous. For example I want to create a 2d side scroller just to see if I could do it. I have the player animation and screen scrolling working however I created 2 .bmp files that were 640x480 and would just load the next when the player gets close to the edge of the screen. These images are 900kb each. I know I can reduce the file sizes but my main question is how do you reduce them without losing quality of the game?

Thanks in advance.

Joe
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 6th Oct 2011 15:05
well loading consists of 2 parts:
1- reading the file
2- creating the Direct3D(2D?) resource

what you can do is avoiding the reading part, i'm afraid this is a little bit advanced but here's the idea:
you will have 2 threads, if not more, 1 for your typical game code, and the rest are used for reading files, basically, you CAN'T create the resource in any thread except the main thread, so you will tell the main thread that you (the loading thread) have read the file and info is ready to be used to make the resource, so you, during the typical game loop in the main thread, will spot the signal and then create the resource, creating the resource is not very heavy so it might not impact the performance by a great amount, though, i'd say only create 1 resource per loop max, so you won't have huge fps drops

i really am not sure if you could do this in GDK - someone with a little bit more of experience could answer: "can you create a GDK image from raw pixels in memory?", as for reading, i don't think there are DirectX9 helper functions for this, but i'll take a look

good luck, this would be a very thing to have in your game

wtfsven
13
Years of Service
User Offline
Joined: 1st Oct 2011
Location:
Posted: 6th Oct 2011 19:31
The way I've seen this handled in the past is pretty much exactly like you say, but with some modifications.

Assuming you are using one big image for your map, it would NOT be too memory-intensive to use even a 3000x3000 pixel map. Additionally, DarkGDK will do all the clipping for you, so all that needs to be processed would be the part of the map currently drawn on the screen. In order to give the effect of moving on the map, you would move the background image as needed.
For example, say you have a 640x480 screen and a player that stays in the middle of the screen. In order to simulate movement, you initially draw the background image at, say, (-1500,-1500), and when the player presses a movement key, you would move the background by a set number of pixels per frame.
If you wanted to do a Zelda-style movement, you would move the player until until he reaches a certain point on the screen, then one that border is reached, you would move the background a stop moving the player. Once the player stopped moving or moved in the opposite direction, you would start moving the player and stop moving the background.

Hope this helps.

2A6X1B
Jcamden
13
Years of Service
User Offline
Joined: 5th Oct 2011
Location: Washington
Posted: 6th Oct 2011 23:07
Good points both of you. So just to clarify I can make a 3000 x 3000 pixel map and just use a camera to only show a certain amount of the map?

Thanks again in advance.
-Joe

Joe
wtfsven
13
Years of Service
User Offline
Joined: 1st Oct 2011
Location:
Posted: 8th Oct 2011 13:38
Yes. In a 2D game, the "camera" would be the view of the window you're drawing in.

2A6X1B

Login to post a reply

Server time is: 2024-11-19 07:34:22
Your offset time is: 2024-11-19 07:34:22