PDA

View Full Version : ShowImg layers


i8bit
01-09-2014, 06:58 PM
How would I draw the image in the showImage function under the player?

showImg(1, "block.png", player.x-0.3, player.y+1.3);
changeImgVis(1, 1);

I tried -1 but it didn't work

Torankusu
01-09-2014, 08:18 PM
probably a better way to do this than my suggestion, but:


findimg(index).layer = 0;

will draw that on a layer below the player's.

100Zero100
01-14-2014, 04:12 AM
You're on the right track.

showimg(200, "block.png", 30, 30);
changeImgVis(200, 0);

That would work in the "traditional" way (ie, in GS1 that is how you'd need to do it, minus the quotes and parentheses).

temp.img = showimg(200, "block.png", 30, 30);
img.layer = 0;

.. would be a nice way to do it in GS2. However,

showimg(200, "block.png", 30, 30).layer = 0;

would also work.

The reason yours didnt work is because you tried -1. -1 and floats don't work. In addition, visibility above 4 will draw to the player's screen's XY, so be wary of that.

Finally, be careful when dealing with showimg indices lower than 200, as they by default will show serverside unless disabled in server options. As a method of protocol, tend to start with image indices greater or equal to 200.

One final tip, if I may, is that if you want fractional-layer showimg, use showimg2.

For example, if you want 2 images to draw under player, but img1 to draw under img2, give img1 a 'z' value of 1 (and increase its y by 1 to compensate, so it doesn't move). Due to its higher z, it'll draw over the other image on the 0-layer, but it'll still draw under players on the 1-layer.

i8bit
01-18-2014, 12:36 AM
probably a better way to do this than my suggestion, but:


findimg(index).layer = 0;

will draw that on a layer below the player's.

Let's say I have an image with the layer set to 0...
IS IT POSSIBLE to have certain tiles draw over that layer?

For example if I have "block.png" with the layer set to 0 in a ShowImg, how do I get the very top left tile in a tile set to draw over the block, but under the player?

Torankusu
01-18-2014, 01:57 AM
Let's say I have an image with the layer set to 0...
IS IT POSSIBLE to have certain tiles draw over that layer?

For example if I have "block.png" with the layer set to 0 in a ShowImg, how do I get the very top left tile in a tile set to draw over the block, but under the player?

i am having a hard time trying to picture what you're trying to do?

can you take some screenshots of what you have or are working on?

there is a tile layer feature,
but it sounds like you're trying to do something that can be done in a completely different manner...and much easier...

i8bit
01-18-2014, 02:57 AM
Okay, the red in this picture is the showImg.
The grass is the top left two tiles. The tiles are showing over the image.

Torankusu
01-18-2014, 03:13 AM
Okay, the red in this picture is the showImg.
The grass is the top left two tiles. The tiles are showing over the image.

Are there any functions that the showimg NPC needs to perform? I.e. does this correlate with the hurting of the player you were trying to do a few threads ago?

A little more insight as far as what you want to do would be extremely helpful -- trust me.

Many of us here are capable of scripting our own versions of whatever you are trying to do, so don't worry about someone stealing your idea -- it's very likely it's already been done before anyway, and if it hasn't, then posting it for the community to see is beneficial to those trying to learn.

i8bit
01-18-2014, 03:27 AM
Are there any functions that the showimg NPC needs to perform? I.e. does this correlate with the hurting of the player you were trying to do a few threads ago?

A little more insight as far as what you want to do would be extremely helpful -- trust me.

Many of us here are capable of scripting our own versions of whatever you are trying to do, so don't worry about someone stealing your idea -- it's very likely it's already been done before anyway, and it it hasn't, then posting it for the community to see is beneficial to those trying to learn.

The red is simply a backing image that will show sky. I am working on a platform engine and I want the back layer to stay constant while the player can move through out the level.

Sorta like the picture I put of the sonic screen shot. The ground would be the tiles, and the backing would be a showImg.
(I have a set screen size)

Torankusu
01-18-2014, 04:03 AM
The red is simply a backing image that will show sky. I am working on a platform engine and I want the back layer to stay constant while the player can move through out the level.

Sorta like the picture I put of the sonic screen shot. The ground would be the tiles, and the backing would be a showImg.
(I have a set screen size)

Hm, i gotcha.

I can't think of an easy or effective way to do that with showimg, as even with tile layers, tiles do not seem to display above an image displayed with showimg even on layer 0. Alternatively, the background could be tiled as well (probably easiest method, but it would eliminate the possibility of having animated backgrounds unless you got creative and displayed some images in the locations that needed to be animated...). You could make a custom Type 1 tileset as there are many non-blocking spaces and possibilities that could be used for background purposes.

Maybe someone with a bit more experience or insight could chime in.

On a slightly related note:
Dusty did release a platformer some years ago, and I just found out about it myself recently.

http://forums.graalonline.com/forums/showthread.php?t=134257875

He does not have backgrounds in it, but it could be possible to make up some background tiles, and just use those as a background...

i8bit
01-18-2014, 04:15 AM
Hm, i gotcha.

I can't think of an easy or effective way to do that with showimg, as even with tile layers, tiles do not seem to display above an image displayed with showimg even on layer 0. Alternatively, the background could be tiled as well (probably easiest method, but it would eliminate the possibility of having animated backgrounds unless you got creative and displayed some images in the locations that needed to be animated...). You could make a custom Type 1 tileset as there are many non-blocking spaces and possibilities that could be used for background purposes.

Maybe someone with a bit more experience or insight could chime in.

On a slightly related note:
Dusty did release a platformer some years ago, and I just found out about it myself recently.

http://forums.graalonline.com/forums/showthread.php?t=134257875

He does not have backgrounds in it, but it could be possible to make up some background tiles, and just use those as a background...


Well I appreciate the input. And I actually Have the whole platform engine done and it runs great. I may put a video of it in, and perhaps post the script because I don't know if I'm going to peruse through with the server, rather than use it as a playground to home my scripting skills.
Still new to GS2 but learning everyday!

Torankusu
01-18-2014, 04:19 AM
Well I appreciate the input. And I actually Have the whole platform engine done and it runs great. I may put a video of it in, and perhaps post the script because I don't know if I'm going to peruse through with the server, rather than use it as a playground to home my scripting skills.
Still new to GS2 but learning everyday!

is it functioning online currently?
you can PM me the server name and I could come check it out?

i8bit
01-18-2014, 01:55 PM
is it functioning online currently?
you can PM me the server name and I could come check it out?

I need to touch it up, and I'll be sure to PM and let you come take a peek.

BUT while we're on the subject on platformers...

What if instead of tiles, I used ground NPCS, like 128x32 big.

Would that be too many NPCs per level??
Would I have lag or any other problems?

Torankusu
01-18-2014, 04:52 PM
you could probably just make a big 64tiles x 64tiles image to lay down on a level and use setshape2 to define how parts of the image work.

this could be both a good and bad thing, depending on how many levels you plan on having and is probably a hackish method to achieve what you want..

TServerNPC.setshape2(int, int, obj) - enables tile-based blocking behaviour. Parameters are tile width, height and an array of tile types; you have to set it on both server-side and client-side to make it blocking on both server and client

Here is some information about setshape2 and tiletypes
http://wiki.graal.net/index.php/Tiletype

i8bit
01-18-2014, 06:52 PM
Can you set the layer of the player?
like...
player.layer = 2;??

I have an image with the layer of 1 but I need it to draw under the player.
NOTE: I don't wanna use drawunderplayer()

Torankusu
01-18-2014, 07:22 PM
See:



The reason yours didnt work is because you tried -1. -1 and floats don't work. In addition, visibility above 4 will draw to the player's screen's XY, so be wary of that.

Finally, be careful when dealing with showimg indices lower than 200, as they by default will show serverside unless disabled in server options. As a method of protocol, tend to start with image indices greater or equal to 200.

One final tip, if I may, is that if you want fractional-layer showimg, use showimg2.

For example, if you want 2 images to draw under player, but img1 to draw under img2, give img1 a 'z' value of 1 (and increase its y by 1 to compensate, so it doesn't move). Due to its higher z, it'll draw over the other image on the 0-layer, but it'll still draw under players on the 1-layer.

i8bit
01-19-2014, 02:04 PM
barQFX_UbQ0&

Here's a sample of what I've been messin with..

i8bit
01-19-2014, 11:06 PM
Shows the backing sorta move as the player jumps.

Torankusu
01-19-2014, 11:46 PM
potential there.
what is with the odd red thing at the bottom?

i8bit
01-20-2014, 12:10 AM
potential there.
what is with the odd red thing at the bottom?

It's a test HUD.

Hezzy002
01-20-2014, 05:18 AM
imm the king of layers

i8bit
01-21-2014, 02:59 PM
So I have a few final questions about the showImg functions if you guys don't mind...

1. How do I rotate an image in the showImg?

2. What is the greatest size (in pixels) that I can have in a showImg with the index being below 200? (So other players can see)
I know if the image is too large, it won't show

Hezzy002
01-25-2014, 04:14 PM
What is the greatest size (in pixels) that I can have in a showImg with the index being below 200? (So other players can see)
I know if the image is too large, it won't show

imo you should never rely on this mechanic and instead use other means

cbk1994
01-25-2014, 09:16 PM
imo you should never rely on this mechanic and instead use other means

+1 but to answer the question:

A weapon needs to display a showimg with index between 1-200 and the size must be less or equal to 128x128 pixels. Alternatively you can also use ganis as player.attr[], although showimg should be fine as long as you don't want to display a lot.

128x128

i8bit
01-26-2014, 12:25 AM
+1 but to answer the question:



128x128

Ah gotcha..

How would I do a horizontal flip of an image on the y axis?

findImg(index).flip ??