What should my next "How to" be?

Game Editor comments and discussion.

Which should me my next "How To" series?

How to make an RPG
5
83%
How to mane a Sidescrolling Adventure game
0
No votes
How to make "Other"
1
17%
 
Total votes : 6

Re: What should my next "How to" be?

Postby Hblade » Fri Oct 14, 2011 2:06 pm

Evan:
You remind me of sgt.sparky o.o
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: What should my next "How to" be?

Postby HitoV » Fri Oct 14, 2011 9:49 pm

If the only way the computer can get the item it needs is by digging through all the piled up artifacts then it will slow down your game. But if you have a sorted list, any time the computer needs something it will be sitting on or near the top at all times.


That summed it up well for me :D Man, that sounds complex, I spent the day looking through some of yalls programs (Evan and Gag.) (BTW, howdy from Texas, LOL.) Anyway, its such intense stuff, if I take everything step by step I can understand most of it but there are just a few things I am like... what the hell?!?! And then I have to turn and ask my cat... which results in... well, nothing. Good stuff, thanks for the enlightenment!
HitoV
 
Posts: 48
Joined: Sat Aug 27, 2011 8:22 am
Score: 3 Give a positive score

Re: What should my next "How to" be?

Postby Game A Gogo » Sat Oct 15, 2011 2:22 am

HitoV wrote:
If the only way the computer can get the item it needs is by digging through all the piled up artifacts then it will slow down your game. But if you have a sorted list, any time the computer needs something it will be sitting on or near the top at all times.


That summed it up well for me :D Man, that sounds complex, I spent the day looking through some of yalls programs (Evan and Gag.) (BTW, howdy from Texas, LOL.) Anyway, its such intense stuff, if I take everything step by step I can understand most of it but there are just a few things I am like... what the hell?!?! And then I have to turn and ask my cat... which results in... well, nothing. Good stuff, thanks for the enlightenment!


If there are things on my part that confuses you, ask away! I'll gladly walk you through my code :)
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: What should my next "How to" be?

Postby EvanBlack » Sat Oct 15, 2011 3:09 am

My code is.... not so well put together at the moment... It uses basic programming and basic usage of gE (as I am still learning it). Its not optimized for best usage. Its just available for understanding it could be done with the basic programming knowledge.

By basic I mean, "Variables and Variable setting, For's and If loops, Functions (mostly void), (almost all integers) Arrays."

Its just how they are stacked that makes them seem more complicated than they are. When I get in the optimization stages of my projects I will heavily comment and show better ways of creating something. I'm not the best optimizer, so my code will stay pretty basic, using char arrays instead of int arrays. I would like to use bit shift but I feel that's too advanced but can be processor heavy if not used properly, a lot of math.


For all programming you just have to master a few things. Maybe you should do a tutorial on this stuff Hblade.

Beginners:

Setting Variables: int's, float's, char's, and double's

Creating functions: void and return functions

Loops, Loops, and More Loops: if, switch, for, and while

Arrays and Iteration: int and char arrays (aka the string), use of the for loop with arrays

Multi-dimensional Arrays: 2D and 3D, make mention of the (n)D arrays but they aren't really needed.



Intermediate:

Pointers: The usage of and safety guide, Don't play with them or you may put an i out. (of bounds)

Malloc: The deadly countess, The usage of and safety guide, How to allocate and free memory for usage.

Dynamic Arrays: How to combined Malloc, Pointers, and Arrays to make magic. The black arts of programming.

Array Sorting: To make your array work for you, Make your CPU tax free!

Struct: How to make a structure! These are wonderful little things that are like an array except they hold more than one type of variable.

Linked Lists: Using Struct + Pointers to make a list that can be iterated and sorted.

Vectors: 2D and 3D, This will become useful when the next version of gE comes out.


Other:

Debugging: The real programmers job. How to work through your own code to find problems

Optimizing: How to have patience and learn to use the best methods for the job.



And I can't think of anything else at the moment.. But after/during the basics of programming cover EVERYTHING in the script reference, and proper usage of it.

Also cover common functions used for making games and make games using them XD.

I hope that helps.
(\__/) ( Soon... The world)
(O.o )< will be mine!____)
(> < )
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Bunny Overlord 2012!
EvanBlack
 
Posts: 202
Joined: Fri Sep 30, 2011 10:17 am
Score: 19 Give a positive score

Re: What should my next "How to" be?

Postby HitoV » Sat Oct 15, 2011 3:40 am

Thanks dudes!
Gag: I just might have some questions to ask about space travalar :D Yeah it does not run very fast but what is does is simply amazing to me.

Evan: Thanks!!! That is a pretty awesome list because it is VERY accurate. At least for me.
In the beginners I understand the first 3 very well, I roughly understand Arrays but not as well as I'd like to. On the other hand, I know little to nothing about pointers and malloc etc.
I get how to copy and paste others codes for pointers and modify them to do what I want, but I don't understand exactly how they work. I appreciate you sharing your code man! I am learning a lot from it!

And because of your advice Gag, I have recoded my entire game to use as little if statements as possible. Almost done, just have to finish one more level. I had my level and players actors doing tons of if statements per draw so I imagine it should make some difference :D Well see soon. Pizza calls first though!

edit: Sadly it didn't actually seem to make any difference.
HitoV
 
Posts: 48
Joined: Sat Aug 27, 2011 8:22 am
Score: 3 Give a positive score

Re: What should my next "How to" be?

Postby Game A Gogo » Sat Oct 15, 2011 12:52 pm

EvanBlack wrote:I would like to use bit shift but I feel that's too advanced but can be processor heavy if not used properly, a lot of math.


you mean << and >>?
Think of binary
you have 0010 (or 2)
do <<1 and you get 0100 (or 4)
do <<2 and you get 1000 (or 8 )

Now these operator are bitwise, meaning they work in binary, so that is less math for your cpu, because you're cpu understands it very well!
<< shifts bits to the left, and >> shifts bits to the right!
"Why would I use that?" you might say, well there is a way to use it to cut off some values.
Let's say you have 3 values inside one unsigned integer, for exemple 3 char's to use for RBG (MUST BE UNSIGNED FOR THIS PURPOSE!)

Code: Select all
colr=col>>16;
colg=(col<<16)>>24;
colb=(col<<24)>>24;


Now I'll explain what this does.

imagine we have 255,127 and 64 for R, G and B values (respectively)
That'd give us an integer of 16744256 (In hex it would be FF 7F 40)
in binary it would be
Code: Select all
0000 0000 1111 1111 0111 1111 0100 0000
|-blank-| |--Red--| |-Green-| |-Blue--|

there is blank space at the beginning since on a 32-bit CPU, well, there's only 32-bits to work with.
(So watch out for 64-bits CPU, although there's a way around this, I'll figure it out later and explain it in a bit)

so if you push the bits to the right by 2 bytes (or 16 bits thus >>16)
it would give out
0000 0000 0000 0000 0000 0000 1111 1111
or 255 (00 00 FF), since when you push bits off the edge, they are lost!

so if you'd want to get your Green value, you'd have to get rid of the red values!
simple, push them off the edge with <<16 which will give:

0111 1111 0100 0000 0000 0000 0000 0000
or 2134900736 (7F 40 00 00)

not quite what you want so we'll need to push off the blue too!
This is where the >>24 comes in handy, to give you:

0000 0000 0000 0000 0000 0000 0111 1111
or 127 (00 00 7F)

so if we follow this for the blue value...

<<24 gives us:
0100 0000 0000 0000 0000 0000 0000 0000
or 1073741824 (40 00 00 00)
>>24 gives us:
0000 0000 0000 0000 0000 0000 0100 0000
or 64 (00 00 40)

And there you have it! :3

now how to make this work on 64-bit CPU's?
we'll use sizeof(int), since that gives us 4 bytes on a 32-bit CPU, I could only assume it'd give us 8 bytes on a 64-bit CPU!

Code: Select all
short unsigned int intl=(sizeof(int)*8)-32;
colr=col>>16;
colg=(col<<(16+intl))>>(24+intl);
colb=(col<<(24+intl))>>(24+intl);


This should work (It did when I put it out visually on notepad!)
Perhaps someone with a 64-bit CPU could test it out with this:
Code: Select all
short unsigned int intl=(sizeof(int)*8)-32;
textNumber=(16744256<<(16+intl))>>(24+intl);

if textNumber == 127, then it works!!
It works on 32-bit cpu

Hope this clears things up about the wonderfullness of << and >> Evan!

also for people who are going to use the code provided to store color values inside one integer...

Code: Select all
const unsigned int CT_red=16711680;
const unsigned int CT_dark_red=8323072;
const unsigned int CT_light_red=16744319;
const unsigned int CT_green=65280;
const unsigned int CT_dark_green=32512;
const unsigned int CT_lightgreen=8388479;
const unsigned int CT_blue=255;
const unsigned int CT_dark_blue=127;
const unsigned int CT_light_blue=8355839;
const unsigned int CT_white=16777215;
const unsigned int CT_light_gray=12566463;
const unsigned int CT_gray=8355711;
const unsigned int CT_dark_gray=4210752;
const unsigned int CT_black=0;


here's a short color list :P
Last edited by Game A Gogo on Sat Oct 15, 2011 1:05 pm, edited 1 time in total.
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: What should my next "How to" be?

Postby Game A Gogo » Sat Oct 15, 2011 1:00 pm

Excuse my double posting...

HitoV wrote:Thanks dudes!
Gag: I just might have some questions to ask about space travalar :D Yeah it does not run very fast but what is does is simply amazing to me.


Go right ahead! though I suggest you do it on: viewtopic.php?f=6&t=11019 :)

HitoV wrote:edit: Sadly it didn't actually seem to make any difference.

Hmm, perhaps it was not the if's that was the issue? Try adding CollisionState("Event Actor", DISABLE); on actors that do not require any collision, since every frame all actors will check if they collide with something even if they don't have a collision event
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: What should my next "How to" be?

Postby EvanBlack » Sat Oct 15, 2011 7:11 pm

Awesome explanation of Bit shifting! While that is still VERY confusing XD The shortcut list at the bottom seems useful.

So basically <<n shifts the bits over that many places in the binary code, dependent on the size of the datatype?

To get a clean value you have to shift all the bits off the memory block?

So...

0001 = 1;

<<1 == 1 = 2

where as:

<<3 == 1 = 8;

in the binary pattern of
Code: Select all
  0 | 0 | 0 | 0 ||1||0||0||0| == 8
[128][64][32][16][8][4][2][1]
(\__/) ( Soon... The world)
(O.o )< will be mine!____)
(> < )
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Bunny Overlord 2012!
EvanBlack
 
Posts: 202
Joined: Fri Sep 30, 2011 10:17 am
Score: 19 Give a positive score

Re: What should my next "How to" be?

Postby Game A Gogo » Sat Oct 15, 2011 10:22 pm

yep!
So basically doing <<1 multiplies by two, <<2 multiplies by four, <<3 multiplies by 8 and <<n multiplies by 2^n
The >> is the same, but with divisions!
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Previous

Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest