Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

Bus Error?


  • Please log in to reply

#16
Spidy

Spidy

    Member

  • Topic Starter
  • Member
  • PipPip
  • 11 posts
Here's the .zip file, though. tut3.cpp has my modifications, and the other code that isn't inside the data folder is the original.

Attached Files


  • 0

Advertisements


#17
bdlt

bdlt

    Member

  • Member
  • PipPipPip
  • 876 posts
let's pause the program after reading the 2nd file. it may be crashing before the display has a chance to update.

add at line 9:
#include <conio.h> // getch()

add 2 lines below line 73 which is - spriteBase sunBase("data/sun");
cout << " program halted " << endl;
getch();

compile and run with the 3 new lines. is " program halted " displayed? does the 2nd file look ok, now? press any key to continue. does it crash, now? if "program halted" is not displayed, please provide details of the behavior so we can debug the file reading code.

here's what we are doing - we haven't fixed anything, yet. we have commented out a block of code which has a problem. we are trying to see if we can read the 'info' files. it appeared earlier that reading the files was causing a problem, but I suspect that is not the case. the results of the test above will tell us for sure.

EDIT
as to the counting:
if you see the following, it is expected
count = 0 for 1.bmp
count = 1 for 2.bmp
...
count = 8 for 9.bmp

Edited by bdlt, 15 November 2005 - 12:35 PM.

  • 0

#18
bdlt

bdlt

    Member

  • Member
  • PipPipPip
  • 876 posts
Hi Spidy,

you can ignore post #17 above 'EDIT". the file reading code is fine. the program first crashes at the line below:

itsAnimation[count].image = SDL_DisplayFormat(temp);

it still crashes with only SDL_DisplayFormat(temp);
this is not good news, since this is part of the SDL code.

the next step - compare your code to the original tutorial files and see if anything is missing.

bdlt

EDIT:

try using lesson3.cpp instead of tut3.cpp and make the following changes:
1. rename CSpriteBase.cpp to CSpriteBase2.h
2. rename CSprite.cpp to CSprite2.h
3. modify lines 16 & 17(line numbers may vary on your editor) of lesson3.cpp to:
#include "CSprite2.h"
#include "CSpriteBase2.h"

this compiled and ran using dev-c++

Edited by bdlt, 15 November 2005 - 06:06 PM.

  • 0

#19
Spidy

Spidy

    Member

  • Topic Starter
  • Member
  • PipPip
  • 11 posts
Hmm. Nothing appears to be missing...I think it might be having issues with me changing things from structs to classes and such, though.
  • 0

#20
Spidy

Spidy

    Member

  • Topic Starter
  • Member
  • PipPip
  • 11 posts

try using lesson3.cpp instead of tut3.cpp and make the following changes:
1. rename CSpriteBase.cpp to CSpriteBase2.h
2. rename CSprite.cpp to CSprite2.h
3. modify lines 16 & 17(line numbers may vary on your editor) of lesson3.cpp to:
#include "CSprite2.h"
#include "CSpriteBase2.h"

this compiled and ran using dev-c++


I tried that, and using G++, it did nothing but throw errors at me about class redefinitions and such.
  • 0

#21
bdlt

bdlt

    Member

  • Member
  • PipPipPip
  • 876 posts
you need to remove the #include statements for the .cpp files - see the attachment

you need 5 files CSprite.h, CSprite2.h, CSpritebase.h, CSpritebase2.h, and lesson3.cpp(with the include statements as shown in lesson3.txt).

if it doesn't work on your system with only these 5 files, we can try to debug tut3.cpp.

you may need to create a new folder and copy only these 5 files into it.

Attached Files


  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP