|
|
Help needed : Creating a 2D Camera View
#479624
04/12/20 17:44
04/12/20 17:44
|
Joined: Feb 2013
Posts: 122 Maysville, Ga
Evo
OP
Member
|
OP
Member
Joined: Feb 2013
Posts: 122
Maysville, Ga
|
I have a 2D game. It uses only panels/images and does not require a 3D level. Because of that, I have no true camera to use and I've had to painfully simulate it. My current version works, but I'd prefer to have an actual 2D view to move around instead. It would allow me to keep the large 2D level pos in place and just move the view around.
* Is there a way to create a 2D view that can show the full level (it's a multi layered panel level) and have a smaller bmap view to pan around it?
* Is there a way to actually create a 2D camera by using a similar method?
Last edited by Evo; 04/12/20 18:08.
|
|
|
Re: Help needed : Creating a 2D Camera View
[Re: Evo]
#479628
04/12/20 21:48
04/12/20 21:48
|
Joined: Jun 2007
Posts: 1,337 Hiporope and its pain
txesmi
Serious User
|
Serious User
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
|
Hi, I'm afraid that is only viable on a 3D level where you can place all objects by means of a transformation matrix on the GPU with a low cost. You might use direct drawing functions and emulate the role of a camera of the engine by checking the bounds of the objects against the bounds of a 2d camera and only draw visible objects. Large levels might need a system that adopts the role of the BSP tree, where the objects are grouped by related areas and the view drawing process only checks the bounds of the objects of the current area and its neighbors instead of the full list of objects. I would avoid using panels. I am afraid the engine checks its visibility each frame. For the case, I think it is better to use structs that are managed by you only. The fastest bounds checks are parallel to screen axes.
for each(obj : currentArea.objList)
if(intersectBounds(obj, view))
draw(obj, obj.pos - view.pos + screen_size / 2);
for each(n : currentArea.neighborAreas)
for each(obj : n.objList)
if(intersectBounds(obj, view))
draw(obj, obj.pos - view.pos + screen_size / 2);
|
|
|
|
|
|