Jump to content


Photo

View_current Question


  • This topic is locked This topic is locked
9 replies to this topic

#1 awasel

awasel

    GMC Member

  • New Member
  • 27 posts

Posted 27 February 2006 - 12:59 PM

Hi FOlks,


When I set

view_visible[0]=0;
view_visible[1]=1;


The view_current variable stays "0". Why is that so? Shouldn't it repesent the actual drawn view, in this case view 1?

I want to draw a HUD, depending on what view currently is drawn. At the moment I have to specify a new global.variable to store which of the two views is actually drawn, so that I can use view_xview[global.variable] f.e.. But I'd like to work with view_current, so that (for me it seems only logic to use it like that) view_xview[view_current] would give me the x-position of the currently drawn view. But as I said, that would not work. view_current stays 0.

So anyone understands this variable view_current? Can it be that the variable changes only in the draw event, and before that represents the view with the smallest numer, i.e. 0??

Anyone,

Greetz

awasel
  • 0

#2 Boggins

Boggins

    Professional Mole

  • New Member
  • 47 posts

Posted 27 February 2006 - 01:14 PM

Well, view_current is the variable that represent the view in wich you're drawing. In the "game loop", it will cycle between all the enabled views you have, just to check if somehing needs to be drawn. But you can put in the event something like this:
{
if (view_current == 0)
  //draw the thing that should be in view0

if (view_current == 1)
  //draw the things that should be in view1
}

I used this before(with 8 views), so I guess it'll work.

Edited by Boggins, 27 February 2006 - 01:22 PM.

  • 0

#3 hpapillon

hpapillon

    GMC Member

  • GMC Member
  • 3019 posts
  • Version:Unknown

Posted 27 February 2006 - 01:14 PM

The view_current variable doesn't 'stay' anything at all, really.

view_current is only used _during the draw event_ to represent which view is currently being drawn, right then and there. You can use it to set one thing to be drawn in one view and not in another. so when view_current is 1, it means the computer is RIGHT THEN drawing things in view 1.

It will start at 0 and go up to 7 or whatever the top view number is during the draw event as the program checks each view to see if it needs to be drawn.

The rest of the time it has no meaning.
  • 0

#4 awasel

awasel

    GMC Member

  • New Member
  • 27 posts

Posted 27 February 2006 - 01:35 PM

I understand. So the best thing would be to do it as I actually do it. Defining a global variable to store, which of the views are actually shown.

Thanx anyway

Awasel
  • 0

#5 Yourself

Yourself

    The Ultimate Pronoun

  • GMC Member
  • 7352 posts
  • Version:Unknown

Posted 27 February 2006 - 03:10 PM

That's not really necessary.

if (view_visible[view_current]) {
   // view_current is 'enabled', draw stuff
}

  • 0

#6 Sinaz

Sinaz

    MCP Killer

  • GMC Member
  • 2751 posts
  • Version:GM8

Posted 27 February 2006 - 06:16 PM

I understand. So the best thing would be to do it as I actually do it. Defining a global variable to store, which of the views are actually shown.

Thanx anyway

Awasel

<{POST_SNAPBACK}>


No... that's not how the application of view_current works.

The idea is that GM processes every object's draw routines per active view...

Let's say that you have a view dedicated to HUD elements. You don't want GM to even consider drawing game elements in the HUD (waste of processor, plus it can cause artifacts if the view space overlaps with another view's space), so you encapsulate all the HUD elements in something like if(view_current=1) and all the game elements in if(view_current=0).

What that does is as GM begins to execute all the draw routines for view[0], the code is telling it "hey, skip this stuff- it isn't supposed to be drawn in this view"
  • 0

#7 hpapillon

hpapillon

    GMC Member

  • GMC Member
  • 3019 posts
  • Version:Unknown

Posted 27 February 2006 - 07:11 PM

The last two answers seem to be missing the point of the question, which was to find out what views are enabled in order to know what x value to draw at.

awasel is, for whatever reason, apparently switching between views, turning one off and another on.

in that case he needs to track which view he has enabled so he can get the x value of THAT view to draw the HUD at.

Why he has two different views, we don't know. :)
  • 0

#8 awasel

awasel

    GMC Member

  • New Member
  • 27 posts

Posted 27 February 2006 - 07:27 PM

Thx for getting the point ;-)

I currently am trying to fix a problem of resolution. The problem is, whenever I switch the resolution of my game (which, for a final game, should be possible) I have problems with the sprites:
If I start the game in 1280x1024, then switch to 1024x768 the gfx are shown in the right size, but they are not sharp, there is like ablur at the edges.

When I start the game in 1024x768, then switch to the bigger res, either the gfx remain in the same size and are getting blurred or the view draws only a 1024x786 big window with the gfx in the right size and sharp.

I really tried every variable from xport to xview to anything which was in the dokumentation, neither worked.

So I decided to try and create two views, one for each resolution. In a *.ini file there would be stored the chosen resolution. When the room is initiated, the corresponding view would be chosen. For that, the HUD must be attached to the current view, because the player can move the view around (that is the room is bigger than the view). For that I needed to track the position of the drawn view.

Phew, so far for explaining.
By the way, the problems with the resolution remain :-(
I never saw any gamemaker game with an option to change the resolution so far...

Greetz

Manuel
  • 0

#9 hpapillon

hpapillon

    GMC Member

  • GMC Member
  • 3019 posts
  • Version:Unknown

Posted 27 February 2006 - 07:43 PM

Settings changes are slightly buggy in GM6. Refresh rate in particular is completely broken, you CANNOT set the refresh rate correctly.

I had to poke around a lot to get Cute Knight to behave itself when switching resolutions and windowed/fullscreen, and a lot of the things that happened didn't make any sense. All I can suggest is experiment a lot.
  • 0

#10 awasel

awasel

    GMC Member

  • New Member
  • 27 posts

Posted 27 February 2006 - 08:09 PM

*gg* that's what I ... feared...

Greetz

Awasel
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users