Page 1 of 2

Edit the Canvas Width and Height

PostPosted: Wed Aug 19, 2009 4:36 am
by Hblade
Edit the Width and Height of the canvas like this
example.gif

Re: Edit the Canvas Width and Height

PostPosted: Wed Aug 19, 2009 10:14 pm
by 4erv'
This could be useful in strategy games! like the ability to resize your territory where you can build your town :D
Great job!
+1 Point

Re: Edit the Canvas Width and Height

PostPosted: Thu Aug 20, 2009 6:48 am
by Fuzzy
It is important when designing a game to decide on resource (CPU/RAM) limits for the player. One should not leave things open to unlimited growth like that. Decide on the maximum canvas size you will use, and if you need a smaller area, just use part of it.

You are the programmer. You must have tight control and constraints on your game if you wish to avoid all sorts of nasty trouble. Both for you and the player. That goes for things like player levels and equipment too.

Resizing canvas means resizing arrays, which is both an intensive use of ram and CPU, and can also run into problems of not enough ram, or not enough contiguous ram. It doesnt matter how fast your CPU is, nor how much ram you own. Resizing an array is slow and prone to failure.

To put it simple, resizing arrays is messy and buggy. Real game makers do not do this.

Re: Edit the Canvas Width and Height

PostPosted: Thu Aug 20, 2009 5:31 pm
by Hblade
Fuzzy wrote:It is important when designing a game to decide on resource (CPU/RAM) limits for the player. One should not leave things open to unlimited growth like that. Decide on the maximum canvas size you will use, and if you need a smaller area, just use part of it.

You are the programmer. You must have tight control and constraints on your game if you wish to avoid all sorts of nasty trouble. Both for you and the player. That goes for things like player levels and equipment too.

Resizing canvas means resizing arrays, which is both an intensive use of ram and CPU, and can also run into problems of not enough ram, or not enough contiguous ram. It doesnt matter how fast your CPU is, nor how much ram you own. Resizing an array is slow and prone to failure.

To put it simple, resizing arrays is messy and buggy. Real game makers do not do this.

Hey fuzzy, it dosnt actually resize anything, when using the lineto function, all it does it go the the set area that you placed, meaning, say... widht, the width is actually a canvas variable I created hehe... in other words, yeah the canvas IS the max width and height >.>

Re: Edit the Canvas Width and Height

PostPosted: Thu Aug 20, 2009 9:42 pm
by 4erv'
Well, I often do not understang these kind of texts (long, and requiring better english understanding), so i will just ask in a simple way:
If i would make a Paint in GE, is there any way to "fill" the canvas with white color? or show the white sprite sized the same as canvas? :D

Re: Edit the Canvas Width and Height

PostPosted: Thu Aug 20, 2009 10:19 pm
by Hblade
4erv' wrote:Well, I often do not understang these kind of texts (long, and requiring better english understanding), so i will just ask in a simple way:
If i would make a Paint in GE, is there any way to "fill" the canvas with white color? or show the white sprite sized the same as canvas? :D

Yep, if you use this fucntion erase(255, 255, 255, 0);

Re: Edit the Canvas Width and Height

PostPosted: Thu Aug 20, 2009 11:45 pm
by Fuzzy
Hblade wrote:
Fuzzy wrote:It is important when designing a game to decide on resource (CPU/RAM) limits for the player. One should not leave things open to unlimited growth like that. Decide on the maximum canvas size you will use, and if you need a smaller area, just use part of it.

You are the programmer. You must have tight control and constraints on your game if you wish to avoid all sorts of nasty trouble. Both for you and the player. That goes for things like player levels and equipment too.

Resizing canvas means resizing arrays, which is both an intensive use of ram and CPU, and can also run into problems of not enough ram, or not enough contiguous ram. It doesnt matter how fast your CPU is, nor how much ram you own. Resizing an array is slow and prone to failure.

To put it simple, resizing arrays is messy and buggy. Real game makers do not do this.

Hey fuzzy, it dosnt actually resize anything, when using the lineto function, all it does it go the the set area that you placed, meaning, say... widht, the width is actually a canvas variable I created hehe... in other words, yeah the canvas IS the max width and height >.>



Sorry. I didnt read it very well, and overlooked the demo. I thought it was a request for resizable canvas. Ignore my rant, ok? :P

Re: Edit the Canvas Width and Height

PostPosted: Fri Aug 21, 2009 7:05 am
by Hblade
Lol sure thing, I didnt know you can actually resize something though

Re: Edit the Canvas Width and Height

PostPosted: Fri Aug 21, 2009 8:45 am
by 4erv'
Hblade wrote:Yep, if you use this fucntion erase(255, 255, 255, 0);


But how to fill only the resized square, not the all "Main window" canvas?

Re: Edit the Canvas Width and Height

PostPosted: Fri Aug 21, 2009 4:21 pm
by Hblade
4erv' wrote:
Hblade wrote:Yep, if you use this fucntion erase(255, 255, 255, 0);


But how to fill only the resized square, not the all "Main window" canvas?

I too was wondering the same thing >.>

Re: Edit the Canvas Width and Height

PostPosted: Fri Aug 21, 2009 9:39 pm
by 4erv'
I have only one idea. To fill it using lineto with a white line that is as wide as the square is :D

Re: Edit the Canvas Width and Height

PostPosted: Fri Aug 21, 2009 9:56 pm
by Hblade
Yeah but that would jsut place 1 line, you need to fill the whole thing up O.o then if you made the size of it large it would make a big giant block, it wouldnt have the curved edges

Re: Edit the Canvas Width and Height

PostPosted: Fri Aug 21, 2009 10:10 pm
by 4erv'
Okay, 20 minutes and all done :D
Here's the demo:
FillSQR.zip
(53.05 KiB) Downloaded 138 times

Re: Edit the Canvas Width and Height

PostPosted: Sat Aug 22, 2009 2:00 am
by Hblade
Hey this is pretty good but if you can make it instant thatd be cool too :D

Re: Edit the Canvas Width and Height

PostPosted: Sat Aug 22, 2009 9:15 am
by 4erv'
i think with function lineto that is not imposible :D