Jump to content


Photo

view_port question ;)


  • Please log in to reply
3 replies to this topic

#1 fenriz

fenriz

    GMC Member

  • GMC Member
  • 10 posts
  • Version:GM8

Posted 24 April 2012 - 09:31 PM

Hi ;)

I have a little problem in my game.

I use a view in my game that follows an abject, but the view also zoom inn and out depending on how fast i'm walking or driving.

So my problem is when im drawing things like an inventory, healthbar etc i get a problem.
I use the code (view_xview and view_yview) to keep it inscreen now and it works when im not zooming.
But when im zooming, the drawing (ofcourse) stays at the same position following the view but not the same place on my screen like i want to.

So is it a way to get the screenport variable. so my inventory stays at the same place even if i change the view??

Thank you for answers in advance(sorry for my english btw) :smile:

(using gm8.1 pro)

Edited by fenriz, 24 April 2012 - 10:21 PM.

  • 0

#2 FoxInABox

FoxInABox

    GMC Member

  • GMC Member
  • 5417 posts
  • Version:GM:Studio

Posted 24 April 2012 - 10:26 PM

well, lets say your view is 640x480 and you change it to 800x600, it was placed at (500,30) at the first view size .. but that doesn't realy matter .. you need to find the position in percent, if you have that then you can use the percent when changing the view to get it at the same position..

500/640 = 0,78
30/480 = 0,06

so when you change the view you do not change theese percentages, only the position:

800*0,78 = 625
600*0,06 = 37

new position will be (625,37)

but after moving it around on the screen by hand then you change the position and recalculate the percentages based on the current view..

hope this makes sence.
  • 0

#3 fenriz

fenriz

    GMC Member

  • GMC Member
  • 10 posts
  • Version:GM8

Posted 24 April 2012 - 11:41 PM

well, lets say your view is 640x480 and you change it to 800x600, it was placed at (500,30) at the first view size .. but that doesn't realy matter .. you need to find the position in percent, if you have that then you can use the percent when changing the view to get it at the same position..

500/640 = 0,78
30/480 = 0,06

so when you change the view you do not change theese percentages, only the position:

800*0,78 = 625
600*0,06 = 37

new position will be (625,37)

but after moving it around on the screen by hand then you change the position and recalculate the percentages based on the current view..

hope this makes sence.







Thank you for your answer ;)

Maby this wil do when i get my head around (alittle tired combined with alittle brainfreze, hehe)

But i do have to find a way to calculate this in each step, because the view is constantly changing. il try too fix it tomorrow.

but thanks for your help and good night ;)

Edited by fenriz, 24 April 2012 - 11:42 PM.

  • 0

#4 fenriz

fenriz

    GMC Member

  • GMC Member
  • 10 posts
  • Version:GM8

Posted 25 April 2012 - 04:15 PM

I have tried putting inn percentages like "foxinabox" suggested, but it doesnt work because the view is following the "player" object. so it changes position also, inn adition too the zoom problem.
So i need too make it follow and move at the same time if you understand. My programming skills is not at a high level so maby this is a simple task. i dont know, but i cant get it right.
I am currently trying to use the "draw health bar" in the draw event of a "health" objekt.

I can send an (.exe) verson of the game to someone if they want too help so that they see the problem..


here is the zooming script if it helps

//fiksing scale
sf=1920/1040
//max zoom
zooming=40
//how fast you zoom
zspeed=5
//reselution view
resw=1248
resh=702



if speed>1 {
if view_wview[0]<resw+speed*(zooming) {
view_wview+=zspeed*sf;
view_hview+=zspeed;
}
if view_wview[0]>resw+speed*(zooming) {
view_wview-=zspeed*sf;
view_hview-=zspeed;
}
}

if speed<-1 {
//turning the variable around, so it works when you are reverseing
speed2=-speed
if view_wview[0]<resw+speed2*(zooming) {
view_wview+=zspeed*sf;
view_hview+=zspeed;
}

if view_wview[0]>resw+speed2*(zooming) {
view_wview-=zspeed*sf;
view_hview-=zspeed;
}
}

Edited by fenriz, 25 April 2012 - 04:25 PM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users