Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (725)
Games in Android Showcase (216)
games submitted by our members
Games in WIP (791)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Slick2d - Fit Camera to game resolution  (Read 1341 times)
0 Members and 1 Guest are viewing this topic.
Offline ral0r2

Senior Newbie





« Posted 2016-11-23 16:11:03 »

Hey guys,

so I've implemented a scrolling camera to my game which works fine for me.
But if I change the resolution of my game, e.g. from 800x600 to 1280x960 the field of view of the player increases extremly.

This is my camera class:
http://pastebin.java-gaming.org/8a70696904d1d

Is there a way to increase screen resolution without increasing the field of view for the player?

Thanks!
Offline ndnwarrior15
« Reply #1 - Posted 2016-11-23 20:05:04 »

I'm not familiar with Slick but it looks like it's wrapped around LWJGL, so concepts are similar but I don't know the functions to make this work. Basically what you want is your projection matrix to scale with the viewport/window.

Offline ral0r2

Senior Newbie





« Reply #2 - Posted 2016-11-24 17:45:59 »

I see the point, unfortunately my knowledge on LWJGL is limitted.
That means I understand your theoretical solution but I have no clue how I could implement it in slick2d Cheesy
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ndnwarrior15
« Reply #3 - Posted 2016-11-24 19:09:12 »

I looked through the index of the Slick 2D javadoc and apparently there is no direct way to access the projection matrix. Nor do i know what version of OpenGL it's using. Sorry buddy, I don't know the API to tell you how to fix your problem but maybe google does.
Offline ral0r2

Senior Newbie





« Reply #4 - Posted 2016-11-24 20:26:48 »

Thanks for the help so far, yeah google didn't help so much yet.
Slick2d, or atleast my version of it is using lwjgl 2.9.1 and this version is so far as i know using OpenGL 4.4
Offline ndnwarrior15
« Reply #5 - Posted 2016-11-25 00:30:05 »

Looks like the issue is going to be solved with the gameContainer. Found this hope it helps
Offline ral0r2

Senior Newbie





« Reply #6 - Posted 2016-12-07 10:18:45 »

Thanks for your help!
As far as I understood the stackoverflow post right this only helps me to change the resolution of the game while it is running?
But it doesn't tell how to fit the pov to the screenresolution nor how to access the projection matrix or did i miss something?
Offline ndnwarrior15
« Reply #7 - Posted 2016-12-07 20:52:07 »

Try changing this

1  
2  
3  
4  
5  
6  
7  
map.render(   
             tileOffsetX + offsetX,
             tileOffsetY + offsetY,
             tileIndexX,
             tileIndexY,
                (gc.getWidth()  - tileOffsetX) / tileWidth  + 1,
                (gc.getHeight() - tileOffsetY) / tileHeight + 1, layer, false);


and switch the gc.getWidth() plus the gc.getHeight to something else, just experiment with it
Offline ral0r2

Senior Newbie





« Reply #8 - Posted 2017-01-06 16:41:42 »

if I change all gc.getWidth & gc.Height in my cameraclass to a fixed value e.g. 800x600 it works.
Thanks for the help. It doesn't look really good tho, but thats another topic Cheesy
Offline ndnwarrior15
« Reply #9 - Posted 2017-01-09 20:25:42 »

Cool, glad to see you got it working
Pages: [1]
  ignore  |  Print  
 
 

 
Archive (54 views)
2017-04-27 17:45:51

buddyBro (266 views)
2017-04-05 03:38:00

CopyableCougar4 (689 views)
2017-03-24 15:39:42

theagentd (691 views)
2017-03-24 15:32:08

Rule (734 views)
2017-03-19 12:43:22

Rule (709 views)
2017-03-19 12:42:17

Rule (713 views)
2017-03-19 12:36:21

theagentd (723 views)
2017-03-16 05:07:07

theagentd (656 views)
2017-03-15 22:37:06

theagentd (497 views)
2017-03-15 22:32:18
List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05

SF/X Libraries
by SkyAphid
2017-03-02 06:38:56

SF/X Libraries
by SkyAphid
2017-03-02 06:38:32

SF/X Libraries
by SkyAphid
2017-03-02 06:38:05

SF/X Libraries
by SkyAphid
2017-03-02 06:37:51
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!