Gamestudio Links
Zorro Links
Newest Posts
Zorro S for Oanda US
by AndrewAMD. 06/06/20 16:39
The Black Book
by SteveG. 06/06/20 14:01
Indicator coding
by danatrader. 06/06/20 11:53
New AUM
by Aku_Aku. 06/06/20 10:10
Reading a TXT file on server
by Truth. 06/05/20 18:22
Oanda instruments
by Morris. 06/05/20 10:24
AUM Magazine
Latest Screens
The Space Between
Pogostuck: Rage With Your Friends
Worst Case Z
AckCon'18 - Lotter vs the World 2 - Preview Release
Who's Online Now
4 registered members (AndrewAMD, SteveG, kalmar, Grat), 472 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Frank_Shieh, PBSeven, Hardi01, Giuseppe, AdamWu
18461 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,322
Hiporope and its pain
txesmi Offline
Serious User
txesmi  Offline
Serious User

Joined: Jun 2007
Posts: 1,322
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