Ooops
November 28, 2020, 02:58:25 AM

Author Topic: [bb] 2D Multiple Resolution Helpers by Jeremy Alessi [ 1+ years ago ]  (Read 546 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
Title : 2D Multiple Resolution Helpers
Author : Jeremy Alessi
Posted : 1+ years ago

Description : It's pretty simple.  There are plenty of times when you want to position some regular 2D text on screen and have it fit right in all resolutions.

Code: [Select]
;Moves mouse to this position relative to a 640 X 480 display, will keep things in order at higher resolutions without needed to plot different points.
MoveMouse(CorrectX(340),CorrectY(452))


Code: [Select]
;Draw the text on the left side of the screen always, but adjust the vertical to be about the 40th pixel in a 640 X 480 display.
Text(0,CorrectY(40),"Keep it up!")


It's really simple but effective. [/i]

Code :
Code: BlitzBasic
  1. ;====== CORRECTX ==========================================================
  2.  
  3. Function CorrectX(pixel)
  4.        
  5.         Return ( pixel * GraphicsWidth() / 640 )
  6.  
  7. End Function
  8.  
  9. ;==========================================================================
  10.  
  11. ;====== CorrectY ==========================================================
  12.  
  13. Function CorrectY(pixel)
  14.        
  15.         Return ( pixel * GraphicsHeight() / 480 )
  16.  
  17. End Function
  18.  
  19. ;==========================================================================


Comments : none...

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal