🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

?2

Started by
15 comments, last by Zekk 22 years, 10 months ago
Thats insanity. I smacked myself in the face. I dont believe it. DO you know how much code I have to write to load a bitmap? If all I have to do to load an img is write


loadimg= ("bitmap.bmp")

I would be pretty pissed off. So if that is in fac the way it works, dont evevn tell me. Please.



"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
Advertisement
Don't trash it, your code should work as it is, you just need to use ==. Just because something is inside an if statement, it doesn't mean the operators work differently. '=' always means assignment. If you done this:

  if(x = 2) { ... }  


What it does is assign 2 to the variable x. This is exactly what it would do even if the expression was outside the if. The code inside an if block is executed if the expression evaluates to non-zero. In this case, after 2 is assigned to x, the result of the expression is x, which is 2 (which is also not zero), and so the if block gets executed. This is not what you want. == will evaluate to 1 if both operands are the same, or 0 if they aren't. This code:

   if(x == 2) { ... }       


This will compare x to 2. If x is equal to 2, then the result will be 1, which will cause the block to be executed. If x is any other value, the if will fail and the else block will be executed.

Does this make sense?

quote: Original post by Drizzt DoUrden:
All you have to do to load an image in C++ is loadimg?


No, don't worry, it is not that easy.

Edited by - Midnight Coder on August 30, 2001 9:12:28 PM
It also looks to me like you are defining loadarray() in int main(). You should have loadarray() separate from main() and call it from main(). Something like this:

  #include #define GRASS 1#define ROCK 2#define FLOWER 3#define WATER 4void 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 );elseloadimg( "water.bmp", 20 * x, 20 * y );}}int main(){int park[12][12];loadarray();}  


Invader X
Invader''s Realm
quote: Original post by Drizzt DoUrden
loadimg= ("bitmap.bmp")

I would be pretty pissed off. So if that is in fac the way it works, dont evevn tell me. Please.


GDI: LoadImage (returns HBITMAP)
DDraw: include ddutil.h - DDLoadBitmap (returns LPDIRECTDRAWSURFACEx)
D3D: I know there''s a function here. I just don''t remember it.
There are many libraries that can load an image for you in 1 line of code. (I use SDL and SDL_Image which does this for pretty much any format, not just BMPs.) The reason you''d learn OpenGL would be to draw the graphics, not to load them.
Ok Zekk, you''ve started learnin C a vew days ago? So why do you start with complex programs (seems you wan''t to make a tile based engine to me) before even understanding the language? I would suggest you start with shorter programms to understand the language first.
Hope that didn''t sound too offending.
I just got the SDL and I am trying to learn how to use it. (I got it like 4 or 5 days ago i think). Actually I am not trying to learn yet because I need to write a story for a game, but soon after I will be learning how to use the SDL.

Zekk, are you learning C or C++? Theres a small difference between the two. C++ is object oriented(the best part of it!!!) and C isnt, whihc are you learning?

"I''ve sparred with creatures from the nine hells themselves... I barely plan on breaking a sweat here, today."~Drizzt Do''Urden

Edited by - Drizzt DoUrden on September 1, 2001 6:54:03 PM
------------------------------Put THAT in your smoke and pipe it

This topic is closed to new replies.

Advertisement