Fixed panel position

Tutorial Fixed panel position 1.0

No permission to download
Panel entities are known to exhibit the behavior of shaking when used as fixed elements on the screen as you move through a level (for example, an entity that replaces the GO arrow or even a custom HUID). Even following the tip of using an image with a size divisible by 4, this never worked for me.

In this example, I am using this code to replace the GO arrow with an animated entity:
pdc - 0201.png


The code works for both DIRECTION RIGHT and DIRECTION LEFT levels and still works in levels even if the camera moves on the Y axis.

INSTRUCTIONS:

- Extract the contents of the zip into your scripts folder, and it will look like this:
data/scripts/update/panel_position.c
data/scripts/update/panel_position_actual.c

- Create your entity where this code will be applied. In my game, I chose TYPE NONE but it works the same way

name customarrow
health 1
nolife 1
setlayer 10000 # important
type none
subject_to_minz 0
subject_to_maxz 0
offscreenkill 9999
nomove 1 1
noquake 0 1
shadow 0

- To optimize memory consumption, we are creating a redirector file - which is what should be called in the header of your TYPE PANEL entity

updatescript data/scripts/update/panel_position.c

or

script data/scripts/update/panel_position.c

(Important - the code does not work perfectly if placed as ondrawscript)

- Open the file panel_position_actual.c, which contains comments explaining what each thing does. There are only 4 lines that matter to us:

Code:
int offsetXright = 440; // X position, for direction RIGHT levels
int offsetXleft = 36; // X position, for direction LEFT levelss
int offsetZ = 100; // Z position on stage
if (name == "arrow_left"){

offsetXright is the X position that the entity will be on the screen in DIRECTION RIGHT levels (needs to be calculated manually, depends on the size of your sprite).

offsetXleft is the X position that the entity will be on the screen in DIRECTION LEFT levels (needs to be calculated manually, depends on the size of your sprite).

offsetZ is the Z position that the entity is on the screen, regardless of the level type.

The last line "if (name == "arrow_left"){" gets the alias of your entity, declared in the txt of your level (and not the original name). If no alias is provided, the code will understand that the level is DIRECTION RIGHT and nothing else needs to be done. For DIRECTION LEFT levels, you need to put the alias "arrow_left" (remembering that scripts are Case Sensitive):

#---- custom arrow - right
spawn customarrow
coords 440 100 # not important, will be replaced by script
at 51

#---- custom arrow - left
spawn customarrow
alias arrow_left
coords 440 100 # not important, will be replaced by script
at 51

With this, even if the camera moves in any direction, the entity will always stay in the same position and without shaking :)

PS: to use this as a custom arrow, you need to replace your arrow.gif sprite (under sprites folder) for an empty image and your go.wav (under SOUNDS folder) with an empty sound file.
  • Like
Reactions: DCurrent
Author
O Ilusionista
Downloads
4
Views
58
First release
Last update

Ratings

0.00 star(s) 0 ratings

More resources from O Ilusionista

Back
Top Bottom