|
Why can't I draw sprites to the screen? |
cameron
Member #8,219
January 2007
|
I simply don't get this. Whenever I run this the game just freezes and i have to use ctrl-alt-delete to end the task. the draw_sprite line is what freezes the game. if i use the commented out draw_rectangle, then it works but isnt the sprite i want.
EDIT: it should be noted that after isolating the problem, i deleted code so you guys dont need to sort through any excess.. EDIT2: just saw a similar thread suggesting i check to make sure the image is being loaded... I will do that now. EDIT3: ok, well I've triple-checked that all filenames are right.. I don't understand why it cant load the image... do i need to change the "working directory" of the program? how do i do this... its in img/character.bmp relative to the executable compiled... argh! |
Richard Phipps
Member #1,632
November 2001
|
Is: |
cameron
Member #8,219
January 2007
|
yes and yes. |
Richard Phipps
Member #1,632
November 2001
|
So, next add error checking to make sure the image is correctly loaded. |
cameron
Member #8,219
January 2007
|
i did. its not being correctly loaded but its in the right spot.. check my original post edits. |
OICW
Member #4,069
November 2003
|
Ok, expected behaviour is, that at [0;0] your image get shown. I don't see any problem with the code. As RP pointed out, try checking if the bitmap was loaded correctly. Oh even try to draw the sprite directly onto the screen (don't forget to comment out blitting buffer). On a sidenote I think that clearing the buffer after the blitting isn't necessary, especially when you're clearing it before drawing. [My website][CppReference][Pixelate][Allegators worldwide][Who's online] |
X-G
Member #856
December 2000
|
If that is in a function, we're obviously not seeing the real code. Show us that. -- |
cameron
Member #8,219
January 2007
|
fixed. apparently i cant place images outside of the folder the executable is in... whatever, works. thanks. |
OICW
Member #4,069
November 2003
|
You can place them in subdirectories, but you have to use proper filenames and dividers between. [My website][CppReference][Pixelate][Allegators worldwide][Who's online] |
Neil Black
Member #7,867
October 2006
|
For future reference, when you include code, include all relevant code. I know I'm bad about including code myself, but when I do I make sure everything someone needs to answer my question is there. You really should have posted your init() function. But since you solved the problem it's OK this time.
|
BAF
Member #2,981
December 2002
|
You want img\\character.bmp, or better yet, img/character.bmp. |
|