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 01-09-2014, 06:58 PM
i8bit i8bit is offline
Registered User
Join Date: Jul 2013
Posts: 146
i8bit is an unknown quantity at this point
ShowImg layers

How would I draw the image in the showImage function under the player?

PHP Code:
 showImg(1"block.png"player.x-0.3player.y+1.3);
 
changeImgVis(11); 
I tried -1 but it didn't work
Reply With Quote
  #2  
Old 01-09-2014, 08:18 PM
Torankusu Torankusu is offline
Elite Member
Torankusu's Avatar
Join Date: Jun 2001
Posts: 10,065
Torankusu is a jewel in the roughTorankusu is a jewel in the rough
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.
__________________
Quote:
Originally posted by Spark910
Think befreo you type.
Reply With Quote
  #3  
Old 01-14-2014, 04:12 AM
100Zero100 100Zero100 is offline
Registered User
Join Date: Jul 2006
Posts: 31
100Zero100 is on a distinguished road
You're on the right track.

NPC Code:
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).

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



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

NPC Code:
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.
Reply With Quote
  #4  
Old 01-18-2014, 12:36 AM
i8bit i8bit is offline
Registered User
Join Date: Jul 2013
Posts: 146
i8bit is an unknown quantity at this point
Quote:
Originally Posted by Torankusu View Post
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?
Reply With Quote
  #5  
Old 01-18-2014, 01:57 AM
Torankusu Torankusu is offline
Elite Member
Torankusu's Avatar
Join Date: Jun 2001
Posts: 10,065
Torankusu is a jewel in the roughTorankusu is a jewel in the rough
Quote:
Originally Posted by i8bit View Post
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...
__________________
Quote:
Originally posted by Spark910
Think befreo you type.
Reply With Quote
  #6  
Old 01-18-2014, 02:57 AM
i8bit i8bit is offline
Registered User
Join Date: Jul 2013
Posts: 146
i8bit is an unknown quantity at this point
Okay, the red in this picture is the showImg.
The grass is the top left two tiles. The tiles are showing over the image.
Attached Images
 
Reply With Quote
  #7  
Old 01-18-2014, 03:13 AM
Torankusu Torankusu is offline
Elite Member
Torankusu's Avatar
Join Date: Jun 2001
Posts: 10,065
Torankusu is a jewel in the roughTorankusu is a jewel in the rough
Quote:
Originally Posted by i8bit View Post
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.
__________________
Quote:
Originally posted by Spark910
Think befreo you type.
Reply With Quote
  #8  
Old 01-18-2014, 03:27 AM
i8bit i8bit is offline
Registered User
Join Date: Jul 2013
Posts: 146
i8bit is an unknown quantity at this point
Quote:
Originally Posted by Torankusu View Post
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)
Attached Thumbnails
Click image for larger version

Name:	MD_Sonic_the_Hedgehog.png
Views:	283
Size:	9.8 KB
ID:	55572  
Reply With Quote
  #9  
Old 01-18-2014, 04:03 AM
Torankusu Torankusu is offline
Elite Member
Torankusu's Avatar
Join Date: Jun 2001
Posts: 10,065
Torankusu is a jewel in the roughTorankusu is a jewel in the rough
Quote:
Originally Posted by i8bit View Post
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...hp?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...
__________________
Quote:
Originally posted by Spark910
Think befreo you type.
Reply With Quote
  #10  
Old 01-18-2014, 04:15 AM
i8bit i8bit is offline
Registered User
Join Date: Jul 2013
Posts: 146
i8bit is an unknown quantity at this point
Quote:
Originally Posted by Torankusu View Post
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...hp?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!
Reply With Quote
  #11  
Old 01-18-2014, 04:19 AM
Torankusu Torankusu is offline
Elite Member
Torankusu's Avatar
Join Date: Jun 2001
Posts: 10,065
Torankusu is a jewel in the roughTorankusu is a jewel in the rough
Quote:
Originally Posted by i8bit View Post
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?
__________________
Quote:
Originally posted by Spark910
Think befreo you type.
Reply With Quote
  #12  
Old 01-18-2014, 01:55 PM
i8bit i8bit is offline
Registered User
Join Date: Jul 2013
Posts: 146
i8bit is an unknown quantity at this point
Quote:
Originally Posted by Torankusu View Post
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?
Reply With Quote
  #13  
Old 01-18-2014, 04:52 PM
Torankusu Torankusu is offline
Elite Member
Torankusu's Avatar
Join Date: Jun 2001
Posts: 10,065
Torankusu is a jewel in the roughTorankusu is a jewel in the rough
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
__________________
Quote:
Originally posted by Spark910
Think befreo you type.
Reply With Quote
  #14  
Old 01-18-2014, 06:52 PM
i8bit i8bit is offline
Registered User
Join Date: Jul 2013
Posts: 146
i8bit is an unknown quantity at this point
Can you set the layer of the player?
like...
Quote:
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()
Reply With Quote
  #15  
Old 01-18-2014, 07:22 PM
Torankusu Torankusu is offline
Elite Member
Torankusu's Avatar
Join Date: Jun 2001
Posts: 10,065
Torankusu is a jewel in the roughTorankusu is a jewel in the rough
See:

Quote:
Originally Posted by 100Zero100 View Post

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.
__________________
Quote:
Originally posted by Spark910
Think befreo you type.
Reply With Quote
  #16  
Old 01-19-2014, 02:04 PM
i8bit i8bit is offline
Registered User
Join Date: Jul 2013
Posts: 146
i8bit is an unknown quantity at this point


Here's a sample of what I've been messin with..
Reply With Quote
  #17  
Old 01-19-2014, 11:06 PM
i8bit i8bit is offline
Registered User
Join Date: Jul 2013
Posts: 146
i8bit is an unknown quantity at this point
Shows the backing sorta move as the player jumps.
Reply With Quote
  #18  
Old 01-19-2014, 11:46 PM
Torankusu Torankusu is offline
Elite Member
Torankusu's Avatar
Join Date: Jun 2001
Posts: 10,065
Torankusu is a jewel in the roughTorankusu is a jewel in the rough
potential there.
what is with the odd red thing at the bottom?
__________________
Quote:
Originally posted by Spark910
Think befreo you type.
Reply With Quote
  #19  
Old 01-20-2014, 12:10 AM
i8bit i8bit is offline
Registered User
Join Date: Jul 2013
Posts: 146
i8bit is an unknown quantity at this point
Quote:
Originally Posted by Torankusu View Post
potential there.
what is with the odd red thing at the bottom?
It's a test HUD.
Reply With Quote
  #20  
Old 01-20-2014, 05:18 AM
Hezzy002 Hezzy002 is offline
Registered User
Join Date: Jul 2011
Posts: 247
Hezzy002 is a jewel in the roughHezzy002 is a jewel in the rough
imm the king of layers
Reply With Quote
  #21  
Old 01-21-2014, 02:59 PM
i8bit i8bit is offline
Registered User
Join Date: Jul 2013
Posts: 146
i8bit is an unknown quantity at this point
A Couple Last Questions

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
Reply With Quote
  #22  
Old 01-25-2014, 04:14 PM
Hezzy002 Hezzy002 is offline
Registered User
Join Date: Jul 2011
Posts: 247
Hezzy002 is a jewel in the roughHezzy002 is a jewel in the rough
Quote:
Originally Posted by i8bit View Post
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
Reply With Quote
  #23  
Old 01-25-2014, 09:16 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Hezzy002 View Post
imo you should never rely on this mechanic and instead use other means
+1 but to answer the question:

Quote:
Originally Posted by Stefan View Post
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
__________________
Reply With Quote
  #24  
Old 01-26-2014, 12:25 AM
i8bit i8bit is offline
Registered User
Join Date: Jul 2013
Posts: 146
i8bit is an unknown quantity at this point
Quote:
Originally Posted by cbk1994 View Post
+1 but to answer the question:



128x128
Ah gotcha..

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

PHP Code:
findImg(index).flip ?? 
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 10:21 PM.


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