Page 2 of 3

Re: Tutorial videos by LCL

PostPosted: Thu Jun 14, 2012 6:56 am
by lcl
I could check it, but I'd hope you to post your GED, because then I could use the exactly same picture as you do and I wouldn't have to copy any code. =)

EDIT: I see one mistake you have done, you have used i two times in different for loops. Change the second of them to something else, like k, which you haven't used yet. (I am not actually sure if this can cause problems, I am just used to use different integers for every for loop..)

EDIT 2: Also, this shouldn't be like this:
Code: Select all
for(j = HEIGHT-1; j <= 0; j--)

but instead:
Code: Select all
for(j = HEIGHT-1; j >= 0; j--)

Because with your code... well I believe you know why it won't work.. the value is never smaller than 0, so it won't run the for loop even once. =D

Re: Tutorial videos by LCL

PostPosted: Thu Jun 14, 2012 1:07 pm
by SuperSonic
Haha, who knew that a small typo like that would keep your entire project from running correctly. It works fine now :lol:
Thanks lcl. +1 as promised :wink:

Re: Tutorial videos by LCL

PostPosted: Thu Jun 14, 2012 1:58 pm
by lcl
SuperSonic wrote:Haha, who knew that a small typo like that would keep your entire project from running correctly.

I did :wink: Actually, one of my attempts on making the part II video failed because of a small typo too. I wrote "j ++" when it was supposed to be "j --". And that made the loop never end, and GE crashed XD

SuperSonic wrote:Thanks lcl. +1 as promised :wink:

Thanks! :)
Hey you used "i" in two different for loops, is it possible to use same integer in many loops in one code? Is there some rules when doing it? I'm curious about that. =)

Re: Tutorial videos by LCL

PostPosted: Thu Jun 14, 2012 3:46 pm
by skydereign
lcl wrote:
SuperSonic wrote:Thanks lcl. +1 as promised :wink:

Thanks! :)
Hey you used "i" in two different for loops, is it possible to use same integer in many loops in one code? Is there some rules when doing it? I'm curious about that. =)

As long as they aren't nested loops it is fine. After all it wouldn't make sense to use the same variable for two different values, but in two different for loops that don't execute at the same time it is perfectly fine.

Re: Tutorial videos by LCL

PostPosted: Thu Jun 14, 2012 3:50 pm
by lcl
Okay, thanks for clearing that, sky! =)

Re: Tutorial videos by LCL

PostPosted: Thu Jun 14, 2012 7:50 pm
by SuperSonic
Aww, Sky beat me to it :P

Re: Tutorial videos by LCL

PostPosted: Mon Dec 31, 2012 3:29 pm
by gamemakerdude
is it possible to do this with .png files?

Re: Tutorial videos by LCL

PostPosted: Mon Dec 31, 2012 8:18 pm
by skydereign
gamemakerdude wrote:is it possible to do this with .png files?

No, not in gE. The format of png files is too complex without something like libpng.

Re: Tutorial videos by LCL

PostPosted: Sun Apr 07, 2013 8:17 pm
by lcl
I added a new tutorial, one that teaches how to show text and numbers (can be used for score, time, etc.) using sprintf() -function. :)

Re: Tutorial videos by LCL

PostPosted: Sun Apr 07, 2013 10:47 pm
by GEuser
Great job! Now if I only had this when I first started gE it would have saved me alot of headache and hair pulling :D

Might be good to do atoi, atof, atol for getting input from text boxes and into variables for next tutorial. I know from experience that this will save people alot of headache.

Oh! for numbers might good to do a quick reveiw of all the math type functions I am thinking: min, max, abs, sign, rand, fmod, ceil, floor, round.

... and thanks lcl :D

Re: Tutorial videos by LCL

PostPosted: Sun Apr 07, 2013 11:01 pm
by lcl
Thanks for commenting GEuser! :)

I've never used atoi, atof, or atol, I guess they're for converting text to variables, integer, float and long, aren't they?

And yeah, you're right I should do a basic math function video, too.
Just have to study them thoroughly first. :wink:

Re: Tutorial videos by LCL

PostPosted: Mon Apr 08, 2013 12:39 am
by GEuser
lcl wrote:Thanks for commenting GEuser! :)

I've never used atoi, atof, or atol, I guess they're for converting text to variables, integer, float and long, aren't they?

And yeah, you're right I should do a basic math function video, too.
Just have to study them thoroughly first. :wink:


Yep, thats what they do. I used them for my genwave viewer thing to get userinput in variables. Here's a quick review with example:

atoi converts text into an integer.
Example:
In a shoot'em up game I want the user to have the ability to specify the amount of ammo at the start of the game. Player types ammo amount in an input text actor (txtInputAmmo) and presses an OK button (buttonOkay) to confirm amount typed in:-

txtInputAmmo (this is a text actor with user input enabled).
buttonOkay (this is the normal actor for okaying ammo typed in)
Code: Select all
// EVENT: buttonOkay->mouse button down( left)

int ammo=atoi(txtInputAmmo.text);

Now 'ammo' variable can be used with in the program code.

so text 0.12 will produce 0 with atoi, 1sdhgddd gives 1, xcetr gives 0, 21.234 gives 21 so on...

atof converts text into an double.
Example:
Code: Select all
// EVENT: buttonOkay->mouse button down( left)

double ammo=atof(txtInputAmmo.text);

so text 0.12 will produce 0.12 with atof, 1sdhgddd gives 1, xcetr gives 0, 21.234 gives 21.234 so on...

atol converts text into an long integer.
Example:
Code: Select all
// EVENT: buttonOkay->mouse button down( left)

double ammo=atol(txtInputAmmo.text);

so text
222222 will produce 222222 with atol,
2222222 gives 2.222222e+06,
22222222 gives 2.222222e+07,
xcetr gives 0
21.234 gives 21 so on...

i don't really use atol so don't see much difference then using atof but I think it allows for much bigger integer values, I tried unsigned long int and other variants but get a big negative exponent value some thing crazy like 5.55444343e-323. This is a skydereign moment. Sky. help! :lol:

[EDIT] my bad for atol i didn't change the %g bit to %i so long int gives max value of 2147483647 anything higher will return this value (although this appears to be same for atoi ... mmmh?

Re: Tutorial videos by LCL

PostPosted: Mon Apr 08, 2013 1:25 am
by skydereign
GEuser wrote:i don't really use atol so don't see much difference then using atof but I think it allows for much bigger integer values, I tried unsigned long int and other variants but get a big negative exponent value some thing crazy like 5.55444343e-323. This is a skydereign moment. Sky. help! :lol:

[EDIT] my bad for atol i didn't change the %g bit to %i so long int gives max value of 2147483647 anything higher will return this value (although this appears to be same for atoi ... mmmh?

That's just because on most compilers there isn't a difference between long ints and ints anymore. It used to be long ints were 32 bit while normal ints were smaller, but as you know, ints are 32 bit as well.

Re: Tutorial videos by LCL

PostPosted: Tue Apr 09, 2013 1:07 am
by GEuser
skydereign wrote:
GEuser wrote:i don't really use atol so don't see much difference then using atof but I think it allows for much bigger integer values, I tried unsigned long int and other variants but get a big negative exponent value some thing crazy like 5.55444343e-323. This is a skydereign moment. Sky. help! :lol:

[EDIT] my bad for atol i didn't change the %g bit to %i so long int gives max value of 2147483647 anything higher will return this value (although this appears to be same for atoi ... mmmh?

That's just because on most compilers there isn't a difference between long ints and ints anymore. It used to be long ints were 32 bit while normal ints were smaller, but as you know, ints are 32 bit as well.


Ah, I see. So long is pretty much redundant. I'll have to check out short int too. The size heirarchy then is 1 bit, 4 bits (nybble = Hex digits), 8 bits = Byte, 16 bits (word), but what is long word (24bits and 32 bits is double word). I'll have to check out short int as well.

Re: Tutorial videos by LCL

PostPosted: Sat May 30, 2015 3:43 pm
by Zivouhr
Interesting and useful information, thanks lcl.