Advertisement

?2

Started by August 30, 2001 07:28 PM
15 comments, last by Zekk 23 years, 2 months ago
Ok I thouhgt I did this code right but.. Did I need a differn''t header file? or what? #include #define GRASS 1 #define ROCK 2 #define FLOWER 3 #define WATER 4 main() { int park[12][12]; loadarray() { int x, y; for( y=0; y < 12; ++y ) for( x = 0; x < 12; ++x ) { if( park[x][y] = GRASS ) loadimg("grass.bmp", 20 * x, 20 * y); else if ( park[x][y] = ROCK ) loadimg( "rock.bmp", 20 * x, 20 * y ); else if ( park[x][y] = FLOWER ) loadimg( "flower.bmp", 20 * x, 20 * y ); else loadimg( "water.bmp", 20 * x, 20 * y ); } }
..
    loadarray(){int x, y;        for( y=0; y < 12; ++y )            for( x = 0; x < 12; ++x )            {  



One thing I see is you forgot the { after the first for


Edited by - Nazrix on August 30, 2001 8:31:25 PM
Need help? Well, go FAQ yourself. "Just don't look at the hole." -- Unspoken_Magi
Advertisement
ahh you sure about that I don''t think I need one there but I tried it with the { but thats not the problem. Maybe the loading of the files?
..
Why is there only a single ''='' in each if? I doubt you meant to do that.

[Resist Windows XP''s Invasive Production Activation Technology!]
I think I need more leasons in C you need == in the if statements?????
..
A single ''='' always means "set the left equal to the right, and this expression is equal to the right". A ''=='' means "This expression is equal to 1 if true, or 0 if false". Now, an if tests statement tests if the statement is nonzero. If it is non zero, then it''s true. Reread those other two explanations, and you''ll see what''s wrong .

[Resist Windows XP''s Invasive Production Activation Technology!]
Advertisement
quote: Original post by Zekk
I think I need more leasons in C you need == in the if statements?????


A single = means assignment - storing something into a variable


a double == means a comparrison ...like you're asking:
"is this equal to this?"

Edited by - Nazrix on August 30, 2001 8:53:16 PM
Need help? Well, go FAQ yourself. "Just don't look at the hole." -- Unspoken_Magi
All you have to do to load an image in C++ is loadimg? Your shitting me right? Thats not even funny. I am learning OpenGL for what then?

"I''''ve sparred with creatures from the nine hells themselves... I barely plan on breaking a sweat here, today."~Drizzt Do''''Urden
------------------------------Put THAT in your smoke and pipe it
Hmm I just trash what I wrote and read more c tut.
..
Not to sure but I thought so to load a map...
..

This topic is closed to new replies.

Advertisement