Recent

Author Topic: How to move around a VirtualScreen?  (Read 2037 times)

JasonLugg

  • Jr. Member
  • **
  • Posts: 67
How to move around a VirtualScreen?
« on: March 26, 2018, 04:01:08 pm »
Hi All

I am using a BGLVirtualScreen on a form (of course). The Control is 900 x 675 on the form. I want to draw to the VirtualScreen and move around (2d) in virtual space.

Thus far I have this:

Code: Pascal  [Select][+][-]
  1. Spr.X:=SceneX;
  2. Spr.OnDraw;
  3.    
  4. BGLContext.Canvas.PutImage(300,300,Plop.Texture,255);
  5.  
  6. BGLContext.Canvas.Translate(Spr.x - 200,0);
  7.  

However, as the sprite moves out of view, the VirtualScreen does not move to follow?

What am I doing wrong?

Thx.

lainz

  • Hero Member
  • *****
  • Posts: 4468
    • https://lainz.github.io/
Re: How to move around a VirtualScreen?
« Reply #1 on: March 26, 2018, 10:04:25 pm »
I think you don't need to move the Virtual Screen.

Usually characters are stick on the center (or another part) of the screen, and what is really moving is the background.

There is no camera, you need to do that.

circular

  • Hero Member
  • *****
  • Posts: 4220
    • Personal webpage
Re: How to move around a VirtualScreen?
« Reply #2 on: March 31, 2018, 08:46:54 pm »
Indeed, if the sprite coordinates go beyond the view, you need to apply a global translation to determine what is visible.
Conscience is the debugger of the mind

 

TinyPortal © 2005-2018