Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / intergers

Author
Message
helpfull programmer
15
Years of Service
User Offline
Joined: 30th Jul 2009
Location:
Posted: 5th Aug 2009 23:38
hello,

is it just me or can I not get intergers to work in the while loop of dark gdk and to transfer into diffrent function...
can you please tell me how to get intergers to work in the while loop as it just dosen't do the sum's and gives it a weird number... thank you bery much ,
Bran flakes91093
16
Years of Service
User Offline
Joined: 13th Sep 2008
Location: Crazy Land
Posted: 6th Aug 2009 01:06 Edited at: 6th Aug 2009 01:12


Are you initializing your integers when you declare them? ( int i = 0; )
Or are you just putting ( int i; )?

And passing an int to a function is the same as any other variable.



EDIT: Fixed accidental smilies

Your_Health = (My_Mood == HAPPY) ? 100 : NULL;
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 6th Aug 2009 02:21


that won't work lol. you are initiating variables in a loop wrong placement.

New Site! Check it out \/
dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 6th Aug 2009 02:52
Quote: "that won't work lol. you are initiating variables in a loop wrong placement."


What's wrong with it?

prasoc
15
Years of Service
User Offline
Joined: 8th Oct 2008
Location:
Posted: 6th Aug 2009 03:02
I see nothing wrong, you can make local variables as well


Your signature has been erased by a mod
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 6th Aug 2009 05:14 Edited at: 6th Aug 2009 05:16
I think the topic that you need to read up on is whats known as "scope".

Basically, where in your program you declare your variable affects what parts of your program can see it.

Here is an excerpt from MSDN :
(link : http://msdn.microsoft.com/en-us/library/b7kfh662(VS.80).aspx )

Quote: "Visual C++ Language Reference
Scope

C++ names can be used only in certain regions of a program. This area is called the "scope" of the name. Scope determines the "lifetime" of a name that does not denote an object of static extent. Scope also determines the visibility of a name, when class constructors and destructors are called, and when variables local to the scope are initialized. (For more information, see Constructors and Destructors.) There are five kinds of scope:

Local scope A name declared within a block is accessible only within that block and blocks enclosed by it, and only after the point of declaration. The names of formal arguments to a function in the scope of the outermost block of the function have local scope, as if they had been declared inside the block enclosing the function body. Consider the following code fragment:"




Quote: "Because the declaration of i is in a block enclosed by curly braces, i has local scope and is never accessible because no code accesses it before the closing curly brace.

Function scope Labels are the only names that have function scope. They can be used anywhere within a function, but are not accessible outside that function.

File scope Any name declared outside all blocks or classes has file scope. It is accessible anywhere in the translation unit after its declaration. Names with file scope that do not declare static objects are often called global names.

In C++, file scope is also known as namespace scope.

Class scope Names of class members have class scope. Class member functions can be accessed only by using the member-selection operators ( . or –> ) or pointer-to-member operators ( .* or –>* ) on an object or pointer to an object of that class; nonstatic class member data is considered local to the object of that class. Consider the following class declaration:"




Quote: "The class members x and y are considered to be in the scope of class Point.

Prototype scope Names declared in a function prototype are visible only until the end of the prototype. The following prototype declares three names (strDestination, numberOfElements, and strSource); these names go out of scope at the end of the prototype:"




Hope that helps you

EDIT : fixed accidental smileys lol

If it ain't broke.... DONT FIX IT !!!
helpfull programmer
15
Years of Service
User Offline
Joined: 30th Jul 2009
Location:
Posted: 7th Aug 2009 15:24
Thanks for the rapid response.

this is my code, (first time inserting code so hope it goes well...

<code>

void DarkGDK ( void )
{
setup();
int gravityamount = 1;

while ( LoopGDK ( ) )
{
make();
gravitydirection();
gravity(gravityamount);
doubleclick();
collision();


if ( dbEscapeKey ( ) )
break;
dbSync ( );
}

void gravity(int gravityamount);
{
dbMoveSprite(2,gravityamount);
}
</code>

roughly, i have cut diffrent functions out so it just shows the bits that i am working on. but the guys just disapears instantly. mabey moving at 14128562 ppl (pixels per loop)

Login to post a reply

Server time is: 2024-10-01 10:28:26
Your offset time is: 2024-10-01 10:28:26