Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
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
  • 875 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
  • 875 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
  • 875 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