Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-07-2003, 08:06 AM
jake13jake jake13jake is offline
Former Classic Staff
jake13jake's Avatar
Join Date: Dec 2002
Location: Northwest Vermont
Posts: 1,452
jake13jake will become famous soon enough
unsticky focus, equations

When using setfocus, my equations didnt work perfectly at first to keep the screen from sticking off the edge of the levels. ...

My final equations:
viewy=screenheight/32-1.5
viewy=62.5-screenheight/32
viewx=screenwidth/32-1.5
viewx=62.5-screenwidth/32

Why is -1.5 involved with the equations for setfocus in scrolling the sides of the level? I only figured this out by tweaking. Is this a bug? Where does the -1.5 come from? It confuses me ...
Reply With Quote
  #2  
Old 08-07-2003, 03:11 PM
faenix faenix is offline
Registered User
Join Date: Jul 2003
Posts: 56
faenix is on a distinguished road
screenwidth and screenheight measure the width and height of you screen not your level. that means that if your resolution is 800x600, screenheight returns 600 and screenwidth returns 800. likewise many computers use 1024x800, in which it would return a different value. screenwidth and screenheight return different values based on computer resolution.

the way you want to do it is based on tiles. the setfocus command doesn't work off of the position relative to the screen, it works off the position relative to the level. if you try setfocus 32,32; it should be centered in the screen. the reason your equation worked is because your screen size just happens to be the right size... for others it may not work so nicely
__________________
In a mad world, only the mad are sane.
Reply With Quote
  #3  
Old 08-07-2003, 07:19 PM
jake13jake jake13jake is offline
Former Classic Staff
jake13jake's Avatar
Join Date: Dec 2002
Location: Northwest Vermont
Posts: 1,452
jake13jake will become famous soon enough
These are equations for when the view is on the outside border of the level, or at least that's what I want them to be, and they've worked so far (at least for me).

I did it on 1024x768 and 800x600, I checked it with at least 3 different window dimensions on both. 1024x768 is not proportionate to 800x600 although it is close, so I think I'll check on 800x600 again.

I do not want to do this based on tiles. The point of the script is to restrict the view to going into coordinates that are outside of the level (which causes the view to seem like it sticks to the side of the level), which you cannot do without something along the lines of these equations. If you do it by tiles then it is different for everyone with a different window size or resolution. If I'm incorrect with my equation, then I am close.

If screenheight and screenwidth are the size of the computer screen and not the window within which Graal is playing, I don't understand why this would work when you resize the window, although you're probably right about it because I know next to nothing about scripting, or at least that's what I say.



Quote:
Originally posted by faenix
screenwidth and screenheight measure the width and height of you screen not your level. that means that if your resolution is 800x600, screenheight returns 600 and screenwidth returns 800. likewise many computers use 1024x800, in which it would return a different value. screenwidth and screenheight return different values based on computer resolution.

the way you want to do it is based on tiles. the setfocus command doesn't work off of the position relative to the screen, it works off the position relative to the level. if you try setfocus 32,32; it should be centered in the screen. the reason your equation worked is because your screen size just happens to be the right size... for others it may not work so nicely
Reply With Quote
  #4  
Old 08-07-2003, 08:24 PM
Chrisz Chrisz is offline
Registered User
Join Date: Oct 2002
Location: Lost...
Posts: 176
Chrisz is on a distinguished road
Send a message via AIM to Chrisz Send a message via Yahoo to Chrisz
lol the 1.5 comes from the players width... (0.5, 2, 0.5), total width 3.. 3 tiles /2 = 1.5 It's just to keep it all centred on the player.. because x/y returns the top left hand corner of the player :P
__________________
-Chrisz
Reply With Quote
  #5  
Old 08-07-2003, 08:28 PM
KainDaMan KainDaMan is offline
Registered User
Join Date: Jul 2003
Location: Virginia,USA
Posts: 51
KainDaMan is on a distinguished road
Send a message via AIM to KainDaMan
screenwidth and screenheight are the width and height of your graal "window". setfocus, however, doesn't go with these factors. setfocus works with level width and level height (on a standard level, 64x64 tiles) however setfocus can go to -128 to 128 on a gmap, if I'm not mistaken. so using screenwidth and screenheight with setfocus would be pointless.
__________________
---Kain Morbid
Reply With Quote
  #6  
Old 08-07-2003, 08:32 PM
Chrisz Chrisz is offline
Registered User
Join Date: Oct 2002
Location: Lost...
Posts: 176
Chrisz is on a distinguished road
Send a message via AIM to Chrisz Send a message via Yahoo to Chrisz
Isnt it only nine levels that are loaded??

level-tl,level-t,level-tr
level-l, player ,level-r
level-bl,level-b,level-br

If it was only 9, max would be -64,128 for x/y :O
__________________
-Chrisz
Reply With Quote
  #7  
Old 08-07-2003, 08:33 PM
Chrisz Chrisz is offline
Registered User
Join Date: Oct 2002
Location: Lost...
Posts: 176
Chrisz is on a distinguished road
Send a message via AIM to Chrisz Send a message via Yahoo to Chrisz
Sorry for double posting.. but i also noticed you /32 x.x that's wrong... graal tiles are 16x16 pixels ;x... 32x32 = 4 tiles

NPC Code:

viewx=playerx-1.5; if (viewx<0) viewx = 0;


And i think that should be what your looking for You can work out the rest.
__________________
-Chrisz
Reply With Quote
  #8  
Old 08-09-2003, 08:31 AM
jake13jake jake13jake is offline
Former Classic Staff
jake13jake's Avatar
Join Date: Dec 2002
Location: Northwest Vermont
Posts: 1,452
jake13jake will become famous soon enough
When I made this script I was thinking on multiples of 16 and fooling around a bit. I didn't post the entire script but the key equations in it.

I already know it works, so don't say that it won't unless you've checked on something other than 800x600 or 1024x768. I just don't know how it works. I made it without knowing what I was doing is what I'm trying to say.

Like I am saying... I was just working on multiples of 16 because tiles in a row/column of a level are 64, pixels per tile are 16, etc.


Quote:
Originally posted by Chrisz
Sorry for double posting.. but i also noticed you /32 x.x that's wrong... graal tiles are 16x16 pixels ;x... 32x32 = 4 tiles

NPC Code:

viewx=playerx-1.5; if (viewx<0) viewx = 0;


And i think that should be what your looking for You can work out the rest.
Reply With Quote
  #9  
Old 08-09-2003, 08:59 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
All you did was list some equations, you didn't explain how they were used. Are they the imposed limits for focusx and focusy?
__________________
Reply With Quote
  #10  
Old 08-09-2003, 09:35 AM
jake13jake jake13jake is offline
Former Classic Staff
jake13jake's Avatar
Join Date: Dec 2002
Location: Northwest Vermont
Posts: 1,452
jake13jake will become famous soon enough
No, they are the equations for the sides of the levels. They are the equations that the focusx and focusy go to after you go over the imposed limit, which would require the same equations with a < or >.

I explained how they were used, to keep the focus from having a "sticking" effect at the sides of the levels (going outside the borders of the level). This could also keep them from going into other mapped levels.

Quote:
Originally posted by Kaimetsu
All you did was list some equations, you didn't explain how they were used. Are they the imposed limits for focusx and focusy?
Reply With Quote
  #11  
Old 08-09-2003, 09:57 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Quote:
Originally posted by jake13jake
No, they are the equations for the sides of the levels. They are the equations that the focusx and focusy go to after you go over the imposed limit, which would require the same equations with a < or >.
Right, so they are, in fact, the imposed limits for focusx and focusy.

Quote:
I explained how they were used
You explained what they were used for, not how they were used. Anyway, the answer has already been given; setfocus has an automatic offset of (playerwidth/2,playerheight/2) for some reason.
__________________
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 05:56 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.