https://wiki.bennugd.org/index.php?title=Resolution&feed=atom&action=historyResolution - Revision history2024-03-29T13:31:47ZRevision history for this page on the wikiMediaWiki 1.36.2https://wiki.bennugd.org/index.php?title=Resolution&diff=7332&oldid=prevDanko at 10:14, 29 July 20092009-07-29T10:14:00Z<p></p>
<p><b>New page</b></p><div>[[Category:general]]<br />
[[category:variables]]<br />
[[category:predefined]]<br />
[[Category:local variables]]<br />
[[category:librender]]<br />
<br />
[[Local variables|'''Up to Local Variables''']]<br />
<br />
----<br />
<br />
<br />
== Definition ==<br />
=== Local variable ===<br />
'''INT''' resolution = 0<br />
<br />
[[Resolution]] is used to alter the precision of the position of [[process]]es on screen; the level of precision is defined by the value of resolution.<br />
<br />
This simulating of fractions in positions is useful for calculations or animations in need of a high precision in order to work properly. It causes the coordinates of all processes to be interpreted as being multiplied by the value of the local variable resolution, associated with that process. So when a process' [[graphic]] is displayed, it will appear as if the process' [[x]] and [[y]] values were divided by the value of resolution. A resolution of <code>0</code> is interpreted as if it were <code>1</code>.<br />
<br />
The default value of [[resolution]] is 0, so set it to 1 if the correct value is needed.<br />
<br />
=== Screen Resolution ===<br />
The resolution of a screen is the dimensions of the screen in pixels. [[Bennu]]'s default screen resolution is 320×200 pixels. This can be altered by use of [[set_mode]]().<br />
<br />
== Example ==<br />
<pre><br />
import "mod_grproc"<br />
import "mod_time"<br />
import "mod_key"<br />
import "mod_video"<br />
import "mod_map"<br />
import "mod_draw"<br />
import "mod_proc"<br />
import "mod_wm"<br />
<br />
Process Main()<br />
Begin<br />
<br />
// Set screen resolution to 320x200 with a color depth of 8bit<br />
set_mode(320,200,8);<br />
<br />
// Set the FPS to 60<br />
set_fps(60,0);<br />
<br />
// Set resolution for this process (try changing it to see the effect)<br />
resolution = 100;<br />
<br />
// Create a 200x200 cyan circle and assign its graphID to the local variable graph<br />
graph = map_new(200,200,8);<br />
drawing_map(0,graph);<br />
drawing_color(rgb(0,255,255));<br />
draw_fcircle(100,100,99);<br />
<br />
// Set size<br />
size = 10;<br />
<br />
// Set the coordinates at screen position (160,180).<br />
x = 160 * resolution;<br />
y = 180 * resolution;<br />
<br />
// Move around in circles while leaving a trail behind<br />
Repeat<br />
trail(x,y,graph,(int)(0.2*size),get_timer()+1000); // create a mini reflection of this process,<br />
// lasting one second<br />
advance(3*resolution); // advance (3 * resolution) units (= 3 pixels)<br />
angle+=2000; // turn 2 degrees left<br />
frame;<br />
Until(key(_ESC)||exit_status)<br />
<br />
OnExit<br />
<br />
let_me_alone();<br />
map_unload(0,graph);<br />
<br />
End<br />
<br />
Process trail(x,y,graph,size,endtime)<br />
Begin<br />
<br />
// Get the resolution of the process calling this one<br />
resolution = father.resolution;<br />
<br />
// Remain existent until the specified endtime was reached<br />
Repeat<br />
frame;<br />
Until(get_timer()>=endtime)<br />
<br />
End<br />
</pre><br />
Used in example: [[set_mode]](), [[set_fps]](), [[map_new]](), [[drawing_map]](), [[drawing_color]](), [[draw_fcircle]](), [[get_timer]](), [[key]](), [[let_me_alone]](), [[map_unload]](), [[advance]](), [[resolution]], [[graph]], [[size]], [[x]], [[y]], [[angle]], [[exit_status]]<br />
<br />
Here are a few screenshots with different resolutions to display the effect it can have.<br />
<br />
{{Image<br />
| image = resolution1.png<br />
| caption = Resolution at 1<br />
}}<br />
<br />
{{Image<br />
| image = resolution2.png<br />
| caption = Resolution at 2<br />
}}<br />
<br />
{{Image<br />
| image = resolution10.png<br />
| caption = Resolution at 10<br />
}}<br />
<br />
{{Image<br />
| image = resolution100.png<br />
| caption = Resolution at 100<br />
}}<br />
<br />
The effect is clearly visible, so when you are moving processes with graphics around the screen, you might want to consider using a resolution of at least 10 in those processes.<br />
<br />
{{Locals}}</div>Danko