• 12
• 10
• 10
• 13
• 10
• ### Similar Content

• By dgi
Hey all ,
For a few days I'm trying to solve some problems with my engine's memory management.Basically what is have is a custom heap with pre allocated memory.Every block has a header and so on.I decided to leave it like that(not cache friendly) because my model is that every block will be large and I will have a pool allocators and stack allocators dealing with those blocks internally. So far so good I figure out how to place my per scene resources . There is one thing that I really don't know how to do and thats dealing with containers.What kind of allocation strategy to use here.
If I use vector for my scene objects(entities , cameras , particle emitters .. ) I will fragment my custom heap if I do it in a standard way , adding and removing objects will cause a lot of reallocations . If I use a linked list this will not fragment the memory but it's not cache friendly.I guess if a reserve large amount of memory for those vectors it will work but then I will waste a lot memory.I was thinking for some sort of mix between a vector and a linked list , where you have block of memory that can contain lets say 40 items and if you go over that number a new one will be created and re location of the data would not be needed.There would be some cache misses but it will reduce the fragmentation.

How you guys deal with that ? Do you just reserve a lot data ?

dgi
• By EddieK
Hello everyone, I want present my new game which I've been working on for a quite while now.
It's a 2D zombie shooter with lots of cool weapons to choose from. Kill zombies, level up, buy new weapons and go through different levels.

Any feedback is appreciated

• Hi everyone!

Let me represent my first game.

It's mix of arcade and logic (just a little).

Play Market:
Gameplay:

Spiteful UFOs seized the hedgehog commune. Four hedgehog fighting commandos will not give them any chance to destroy it.
Be the fifth member of the team.
Destroy alien’s bases!
Use the commandos’ features to seize and destroy aliens’ bases.
You won’t be able to clean the commune from hateful aliens without rationality, speed and agility.
- 40 fascinating levels in different parts of the world;
- 8 different locations.
I'll wait for yours feedback. It's very important for upcomming updates!
Thanks!!!

• By Hermetix
I am trying to setup the custom wizard for making a 3ds MAX 2018 plug-in (to export a character animation data), but I can't locate the wizard file folder to put the .vsz file in. In the 3ds MAX 2018 docs, it only mentions where the folder is in VS 2015 (VC/vcprojects). It's a VC++ project, but I don't see any folder in VC for the wizard files. I'm using VS 2017 update 15.5.6 Enterprise, and the folders in VC are: Auxiliary, Redist and Tools.

Thanks.

• Hi,
Check it out: habela.github.io
ok, don't know if it is that "cool" or that "unique"... but supposedly being self-confident and brag yourself is a way to go hmm...don't know
Anyway, tell me guys what do you think about my site and art in it as well.
Btw: Say nicely "hi" or "hello" to me coz I'm new here (not so new to game art, as I'm doing it for 2 years now)

# I do not understand side-scrolling implementation in SDL

## Recommended Posts

I've seen some SDL tutorials on implementing side-scrolling, and I don't understand how they do it. All of the tutorials I've seen do it like this:(taken from LazyFoo's code)

	camera.x = ( dot.getPosX() + Dot::DOT_WIDTH / 2 ) - SCREEN_WIDTH / 2;
camera.y = ( dot.getPosY() + Dot::DOT_HEIGHT / 2 ) - SCREEN_HEIGHT / 2;


This part, I at least understand. The camera's position is the position of the dot's origin minus the screen's width or height, because the camera should start moving should the dot's x or y coordinates exceed the middle of the screen. The part which I absolutely don't understand is this:

	void Dot::render( int camX, int camY ) {
gDotTexture.render( mPosX - camX, mPosY - camY );
}


In the above code, where the dot is drawn on the screen is the dot's x and y coordinates subtracted by the camera's x and y coordinates. I don't understand how or why one would come to the conclusion that the dot is to be rendered at the coordinates. I don't understand how it works. Can someone please explain?

##### Share on other sites

Look up translation algebra. One position is world coords other is camera coords. Make a drawing of two rects one inside the other. The inside one is the camera or viewport, outside is world. Do the math. The resulting pos is located around origin such that you can refer to pixels, and draw stuff.

##### Share on other sites
19 hours ago, h8CplusplusGuru said:

Look up translation algebra. One position is world coords other is camera coords. Make a drawing of two rects one inside the other. The inside one is the camera or viewport, outside is world. Do the math. The resulting pos is located around origin such that you can refer to pixels, and draw stuff.

I made the diagram and I think I see what you're saying. The calculations of the camera's x and y coordinates keep the dot in the middle of the camera rectangle, which but the dot's "world coords", as you said, aren't necessarily in the middle of the camera coords, so the position the dot is drawn at is the dot's world coords subtracted by the extra distance the camera has moved from (0,0), which would be the camera's position. Does that sound like a reasonable explanation? Do you think I've understood?

##### Share on other sites

Yes I think your description sounds reasonable. To further elaborate:

So the goal is to draw stuff on the screen. The screen has pixel coords, say, from (0,0) to (800,600). You have your camera position on the world map, and you have your dot, or thing to draw, position on the world map. You do the subtraction of camera from dot, that moves the dot into the cameras view about origin (0,0), which is where your pixels are. You can then draw the sprite on the screen. So doing this for every object that is visible in the camera, you will be able to see somewhere in the world.