BASIC

Author Topic: Bild stretchen oder vergrößern?  (Read 6313 times)

Online spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3587
    • View Profile
    • Space Fractal
Re: Bild stretchen oder vergrößern?
« Reply #15 on: 2015-Dec-29 »
Its very depend on the game and how to deal. There is various methods doing that. The screen ratio is also the main issue.

- in Greedy Mouse did not suffer the issue and just scaled to uses around 12-13 tiles across, and then fill out the screen.
- In Karma Miwa, there was various screen ratio issues and quite annoying here. So here im did some camera panning to make sure its was playable on a 4:3 screen as well on a 16:9 screen.
- Alternative you could also add a Super Gameboy like border around the playfield and just use one scaling. This is seen in example Snake Slider for iOS and also works pretty nice in that game.

Im thinks its the last option you want to do. Until then checkout the code im gave in the codesnippet as well PRESCALER.

Also PRESCALER might not DOWNSCALING correctly? Its was more designed to UPSCALING graphics, also best for retro games.
« Last Edit: 2015-Dec-29 by spacefractal »
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.

Offline LukasOK

  • Mr. Drawsprite
  • **
  • Posts: 56
  • Was kann ich Ihr nur schreiben? =D
    • View Profile
Re: Bild stretchen oder vergrößern?
« Reply #16 on: 2015-Dec-29 »
Then what is probably best for smartphones?

Offline Ian Price

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4141
  • On the shoulders of giants.
    • View Profile
    • My Apps
Re: Bild stretchen oder vergrößern?
« Reply #17 on: 2015-Dec-30 »
The "Prescaler" option can't cope with screens smaller than you initially state in project options.
The virtual scaling solution causes slow-down and like all scaling systems, can look nasty when scaled too high up or down. This will be true of the "prescaler" option too.

You may need a number of sets of assets (graphics) to cope with different sized screens - eg small assets for small screens (phones) and huge assets for tablets with retina displays. Not only do you have to recreate the images for these resolutions, you also have to ensure that your code adapts to positioning these assets.

So you get to choose - easy work, but possibly messy results or perfect results but with an awful lot more work involved. Of course you can meet the options somewhere in-between...
I came. I saw. I played.

Offline LukasOK

  • Mr. Drawsprite
  • **
  • Posts: 56
  • Was kann ich Ihr nur schreiben? =D
    • View Profile
Re: Bild stretchen oder vergrößern?
« Reply #18 on: 2016-Jan-01 »
Englisch/English:
I know that there is more work but I find it nice when everything is the same size.
But how do I do that?

Deutsch/German:
ich weiß dass es mehr arbeit wird ich find es aber schöner wenn alles die gleiche größe hat.
Aber wie mache ich das?

Offline Ian Price

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4141
  • On the shoulders of giants.
    • View Profile
    • My Apps
Re: Bild stretchen oder vergrößern?
« Reply #19 on: 2016-Jan-01 »
Here's a rundown of what you would do to create a virtual screen scaling system.

Firstly you have to get the screen resolution of your target device with GETDESKTOPSIZE w,h

Then you need to work out what the maximum size of your game (maintaining aspect raitio) based on the device resolution and your game screen. Eg if your game screen is 320x240 and your target device is 640x480 then you can scale your game screen by 2 (2x320=640, 2x240=480). If the device resoolution is 800x480 (2x320=640, leaving an empty space of 160 pixels), then you still scale by 2, but have black borders where there is no gamescreen.

Here's a short example of how to create a virtual screen and scale it.

Code: GLBasic [Select]
GLOBAL scale%=2
GLOBAL game_width%=320
GLOBAL game_height%=240

// Create a virtual screen
CREATESCREEN 1,999,game_width, game_height

SETSCREEN 1024,768,0

// Repeat until ESC pressed
WHILE TRUE

// Draw stuff to the virtual screen
USESCREEN 1

 PRINT "PRESS SPACE",20,20

 // Press SPACE to create new image
 IF KEY(57)

  FOR n=0 TO 50
   DRAWRECT RND(320),RND(240),RND(64),RND(64),RGB(RND(255),RND(255), RND(255))
  NEXT
 
 ENDIF
 
// All drawing now done on the main screen
USESCREEN -1
 
 SMOOTHSHADING FALSE
 
 STARTPOLY 999
  POLYVECTOR game_width*scale,0, game_width,0
  POLYVECTOR 0,0, 0,0
  POLYVECTOR 0,game_height*scale, 0,game_height
  POLYVECTOR game_width*scale,game_height*scale, game_width,game_height
 ENDPOLY


 DRAWSPRITE 999,650,10
 
SHOWSCREEN

WEND
 


Change the "scale" value to make the scled image larger/smaller. Change the game_width and game_height to make the game screen larger/smaller.

You can add an OFFSET value in the POLYVECTOR section to have your screen in the middle of a larger screen if required.

Hope that helps. :)
I came. I saw. I played.

Offline LukasOK

  • Mr. Drawsprite
  • **
  • Posts: 56
  • Was kann ich Ihr nur schreiben? =D
    • View Profile
Re: Bild stretchen oder vergrößern?
« Reply #20 on: 2016-Jan-03 »
Englisch/English
Do not be 2 Details?
Normal size and screen size?

Deutsch/german
Muss es nicht 2 Angaben geben?
Normale größe und Bildschirm größe?

Offline Ian Price

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4141
  • On the shoulders of giants.
    • View Profile
    • My Apps
Re: Bild stretchen oder vergrößern?
« Reply #21 on: 2016-Jan-03 »
Eh?

Are you asking why there are two screens being shown? That's to demonstrate that the larger, scaled version is based on the small original version.

I haven't taken into account the actual screen-size (desktop size) in that demo. I don't know what your original game screen size is or your desktop size. I thought that was enough to show you how to scale a POLYVECTOR virtual screen.

If that's not what you're asking then you need to rephrase, I'm afraid.
I came. I saw. I played.