Jump to content


Photo

A Few Function Modifications


  • Please log in to reply
16 replies to this topic

#1 MonkeyMaw

MonkeyMaw

    GMC Member

  • GMC Member
  • 263 posts
  • Version:GM:Studio

Posted 12 September 2012 - 04:14 PM

Hello everyone. Ever since I started with GameMaker, many years ago, there are a few functions I have always wished that I could modify.

Here are the two functions in their current definitions.
draw_sprite_tiled_ext(sprite,index,x,y,xscale,yscale,blend,alpha);
draw_background_tiled_ext(background,x,y,xscale,yscale,blend,alpha);


Here are the two functions, modified.
draw_sprite_tiled_ext(sprite,index,x,y,xscale,yscale,blend,alpha,hrepeat,vrepeat);
draw_background_tiled_ext(background,x,y,xscale,yscale,blend,alpha,hrepeat,vrepeat);


What I'm going for here is the ability to only tile horizontally, vertically, or both as it is now. I think both hrepeat and vrepeat should default to true, in which case it would tile the way it does now. Now currently there are many ways to do this without these two function modifications. You can use primitives, surfaces, recursive loops, etc. I decided to post this because right at this moment, I'm working on some scrolling clouds. They only should tile horizontally, and it's no big deal, I have it working. I just think it would be fantastic to have some control over the tiling. Let me here what you think!

Posted Image

Edited by MonkeyMaw, 22 November 2012 - 01:35 AM.

  • 2

#2 daspirit

daspirit

    The Quiet

  • GMC Member
  • 500 posts
  • Version:GM:Studio

Posted 12 September 2012 - 04:24 PM

I don't like this idea. I don't see myself ever needing those parameters. What we do need with tiles is a way to set up the texture UV coordinates in simple 3D primitives. I don't want to have to make a separate model for every tile.
  • 0

#3 MonkeyMaw

MonkeyMaw

    GMC Member

  • GMC Member
  • 263 posts
  • Version:GM:Studio

Posted 12 September 2012 - 04:30 PM

I don't like this idea. I don't see myself ever needing those parameters. What we do need with tiles is a way to set up the texture UV coordinates in simple 3D primitives. I don't want to have to make a separate model for every tile.

You lost me there. I'm not sure you understand, maybe I didn't explain it correctly. It's not for tiles. It's for tiling backgrounds and sprites. These functions already exist, I wish to have a little control over the tiling is all. I edited my original post and added a screen to better explain :smile:

Edited by MonkeyMaw, 12 September 2012 - 05:14 PM.

  • 0

#4 mcmonkey

mcmonkey

    mcmonkey

  • GMC Member
  • 663 posts
  • Version:GM8

Posted 12 September 2012 - 10:21 PM

I still don't understand - if hrepeat is false, it's the same as a default xscale, isn't it? If vrepeat is false, the same as a default yscale?
...
???
Can you explain more please?

Perhaps an example code using this idea, how it would look, and how that same code looks without the hrepeat/vrepeat settings?

Edited by mcmonkey, 12 September 2012 - 10:21 PM.

  • 0

#5 MonkeyMaw

MonkeyMaw

    GMC Member

  • GMC Member
  • 263 posts
  • Version:GM:Studio

Posted 13 September 2012 - 01:14 AM

I still don't understand - if hrepeat is false, it's the same as a default xscale, isn't it? If vrepeat is false, the same as a default yscale?

Damn. I don't know how to explain it any better to be honest, I even gave a picture. I apologize that I can't describe it any better. Also note that scale has nothing to do with what I'm describing. You must think that scale refers to how many times the background is repeated or tiled. The scale refers to how big the image is when you draw it.

A 64x64 background with a xscale of 1 and yscale of 1 = Appears on your game's screen as 64x64.
A 64x64 background with a xscale of 2 and yscale of 2 = Appears on your game's screen as 128x128.
A 64x64 background with a xscale of 4 and yscale of 4 = Appears on your game's screen as 256x256.

EDIT: You said you wanted to see the current functions without hrepeat and vrepeat, I provided those in the first post. However here they are again. These two functions which already exist in GameMaker, will tile the given sprite or background. These functions fill the entire room. Please refer to the GameMaker documentation. I simply wanted the choice to be able tile ONLY horizontally or ONLY vertically.
draw_sprite_tiled_ext(sprite,index,x,y,xscale, yscale,blend,alpha);
draw_background_tiled_ext(background,x,y,xscale,yscale, blend,alpha);

Edited by MonkeyMaw, 13 September 2012 - 02:07 AM.

  • 0

#6 mcmonkey

mcmonkey

    mcmonkey

  • GMC Member
  • 663 posts
  • Version:GM8

Posted 13 September 2012 - 01:30 AM

No, an example code and how it would turn out
Like
draw_sprite_tiled_ext(spr_block,0,0,500,500,0,1,true,false);
or somesuch, but also how it ends up looking compared to the same code without it, like:
draw_sprite_tiled_ext(spr_block,0,0,500,500,0,1);
  • 0

#7 MonkeyMaw

MonkeyMaw

    GMC Member

  • GMC Member
  • 263 posts
  • Version:GM:Studio

Posted 13 September 2012 - 01:49 AM

:blink: I did exactly that in the first post. I posted the code. I posted how it would look.

Edited by MonkeyMaw, 13 September 2012 - 03:40 AM.

  • 0

#8 mcmonkey

mcmonkey

    mcmonkey

  • GMC Member
  • 663 posts
  • Version:GM8

Posted 13 September 2012 - 02:32 AM

What you posted can be done with the xscale and yscale vars, no need for more variables...
  • 0

#9 MonkeyMaw

MonkeyMaw

    GMC Member

  • GMC Member
  • 263 posts
  • Version:GM:Studio

Posted 13 September 2012 - 03:33 AM

What you posted can be done with the xscale and yscale vars, no need for more variables

I suggest you go try that for yourself. That's not what xscale and yscale do. You don't seem to understand what tiling is. You must think I wish to stretch the background in one direction. Here is what the GameMaker Documentation has to say about xscale and yscale ...

xscale = The horizontal scaling of the background.
yscale = The vertical scaling of the background.

EXAMPLE:
draw_background_tiled_ext(bck_Sky, x, y, 2, 2, c_red, 0.5);

This will draw the background indexed in "bck_Sky" at the instances own x and y position, double it's stored size and tiled in every direction in the room, as well as blended with the color red and partially transparent.

Edited by MonkeyMaw, 13 September 2012 - 03:41 AM.

  • 0

#10 MonkeyMaw

MonkeyMaw

    GMC Member

  • GMC Member
  • 263 posts
  • Version:GM:Studio

Posted 13 September 2012 - 04:56 AM

Sorry, accidental post.

Edited by MonkeyMaw, 31 October 2012 - 03:12 AM.

  • 1

#11 daspirit

daspirit

    The Quiet

  • GMC Member
  • 500 posts
  • Version:GM:Studio

Posted 13 September 2012 - 02:41 PM

I understood what you meant. It's just that your idea isn't great. You can do this sort of functionality using just one extra line (which would be the forloop) and you could even better control it.

Most people won't use it, so it'd just a waste in the runner to include it. I would only support it only if GameMaker allowed Function Overloading and the compiler was optimized so that it would not insert them into the executable unless it's used.
  • 0

#12 MonkeyMaw

MonkeyMaw

    GMC Member

  • GMC Member
  • 263 posts
  • Version:GM:Studio

Posted 13 September 2012 - 02:59 PM

I understood what you meant.

In your post you were referring to UV coordinates, 3D primitives, and models? That's what made me think you did not understand. My apologies.

It's just that your idea isn't great.

Maybe it isn't, I respect your opinion. I feel that people who use parallax backgrounds would disagree but that is simply my opinion. The scripts I provided are indeed useful, you can tile a background in one direction, scroll it, and still adjust it's y coordinate. So I can draw a tiled background, anywhere I wish, rather than filling the entire screen like the built-in functions currently do.

You can do this sort of functionality using just one extra line (which would be the forloop) and you could even better control it.

As I mentioned in my original post. However, I'd like to see your implementation if you don't mind.

Most people won't use it, so it'd just a waste in the runner to include it.

There are a lot of functions in GameMaker which makes it great. I cannot say however that I have used even 50% of the ones that already exist, but I don't consider the remaining 50% to be a waste. They are just functions I've had no use for yet. Anyway, you must be assuming that I want new functions. I do not. I want two functions that already exist, to allow a bit more control.


Overall, this was all just a suggestion. I've tried to back up my idea and reasoning and I feel I have done so, a few times. I have no problems using my current methods and I will continue to do so. I appreciate all of your input, so thank you!

Edited by MonkeyMaw, 13 September 2012 - 04:16 PM.

  • 0

#13 mcmonkey

mcmonkey

    mcmonkey

  • GMC Member
  • 663 posts
  • Version:GM8

Posted 13 September 2012 - 10:26 PM

So I can draw a tiled background, anywhere I wish, rather than filling the entire screen like the built-in functions currently do.

Wait, really?
I don't use GM much so I was confused - I thought one of those variables would specify the region you place the tiles in... why does it not allow you to specify the region? That seems like a better idea than simply which axis to nonsensically fill completely.
  • 0

#14 Erik Leppen

Erik Leppen

    GMC Member

  • GMC Member
  • 2028 posts
  • Version:GM:Studio

Posted 14 September 2012 - 07:22 PM

Hello everyone. Ever since I started with GameMaker, many years ago, there are a few functions I have always wished that I could modify.

Here are the two functions in their current definitions.
draw_sprite_tiled_ext(sprite, index, x, y, xscale, yscale, blend, alpha);
draw_background_tiled_ext(background, x, y, xscale, yscale, blend, alpha);


Here are the two functions, modified.
draw_sprite_tiled_ext(sprite, index,x,y,xscale, yscale, blend, alpha, hrepeat,vrepeat);
draw_background_tiled_ext(background, x, y, xscale, yscale, blend, alpha, hrepeat,vrepeat);


I'd rather have
draw_sprite_tiled_ext(sprite, index, x, y, xscale, yscale, blend, alpha, amount_of_tiles_on_left, amount_of_tiles_on_top, amount_of_tiles_on_right, amount_of_tiles_on_bottom);
draw_background_tiled_ext(background, x, y, xscale, yscale, blend, alpha, amount_of_tiles_on_left, amount_of_tiles_on_top, amount_of_tiles_on_right, amount_of_tiles_on_bottom);


The point is, the tiled functions fill the entire room. I'd rather they just fill the playing field. Then I don't have to cover up everything that it draws that I don't need everytime I use one of these functions.

The idea is that you select one cell and then can extend however many cells you need in each of the four directions. So all four extra arguments to zero means you see only one tile. left = 0, top = 0 means the x and y indicate the left-top-most tile. left = 1 means the x indicates the second-left tile. right = 0 means the x indicates the rightmost tile. I guess you get the idea. One example,
draw_sprite_tiled_ext(sprite, index, x, y, xscale, yscale, blend, alpha, 5, 3, 20, 15);
means it draws the tile at the given x, y position, then five columns left of it and 20 right of it, and then three rows on top and 15 below. So in total this would draw 5 + 1 + 20 = 26 columns and 3 + 1 + 15 = 19 rows, totalling 494 tiles, where the original x, y position incates the fourth row and the sixth column.

That way you have all freedom you could ever need (except rotation).


Need to expand it all over the room?
draw_sprite_tiled_ext(sprite, index, x, y, xscale, yscale, blend, alpha, x div w, y div h, (room-width - x) div w, (room_height - y) div h);
  • 1

#15 MonkeyMaw

MonkeyMaw

    GMC Member

  • GMC Member
  • 263 posts
  • Version:GM:Studio

Posted 14 September 2012 - 08:17 PM

Absolutely Eric, I like that idea as well. I suppose what I wanted maybe a little more specific to what I actually use tiled backgrounds for, and that's scrolling a texture. Usually a cloud texture that is anywhere from 256x128 to 512x256. As you can imagine, it's a pain to tile only one direction, scroll it, and still have proper vertical placement as well. Like I mentioned, I just use a primitive. I just wish I didn't have to. I like the regional idea that you proposed. Thanks for the input bud.
  • 0

#16 mcmonkey

mcmonkey

    mcmonkey

  • GMC Member
  • 663 posts
  • Version:GM8

Posted 14 September 2012 - 10:29 PM

Absolutely Eric, I like that idea as well. I suppose what I wanted maybe a little more specific to what I actually use tiled backgrounds for, and that's scrolling a texture. Usually a cloud texture that is anywhere from 256x128 to 512x256. As you can imagine, it's a pain to tile only one direction, scroll it, and still have proper vertical placement as well. Like I mentioned, I just use a primitive. I just wish I didn't have to. I like the regional idea that you proposed. Thanks for the input bud.

Yeah. That Eric proposed. Riiiight. I take it my posts are invisible...
  • 0

#17 MonkeyMaw

MonkeyMaw

    GMC Member

  • GMC Member
  • 263 posts
  • Version:GM:Studio

Posted 14 September 2012 - 11:05 PM

Yeah. That Eric proposed. Riiiight. I take it my posts are invisible...

Not at all, I apologize. Eric put forth some effort in his post and I felt we understood each other, that's all. After reading a few of your posts, I was under the impression we were on two different pages, but I wasn't going to make a big deal about it.

Edited by MonkeyMaw, 14 September 2012 - 11:06 PM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users