Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (Quad, AndrewAMD, Imhotep, TipmyPip, Edgar_Herrera), 809 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
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 Offline OP
Member
Evo  Offline 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 Offline
Serious User
txesmi  Offline
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.

Code
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);

Re: Help needed : Creating a 2D Camera View [Re: Evo] #479635
04/13/20 12:57
04/13/20 12:57
Joined: Feb 2013
Posts: 122
Maysville, Ga
Evo Offline OP
Member
Evo  Offline OP
Member

Joined: Feb 2013
Posts: 122
Maysville, Ga
Thanks, Txesmi. That's an interesting idea. With draw functions, I'm sure that a 2D camera could be made that way.

At the moment, I'll have to keep my current method which just simulates 2D camera movement. My current 2D projects (A Top-down JRPG and Retro Platformer) aren't tile-based and they use full image files that are layered to create the levels. So far it works fine, but before I get too far into it, I'll probably consider switching from panels to draw functions.


Moderated by  HeelX, Spirit 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1