Here's my source code, based on LazyFoo's tutorials (mad props, http://lazyfoo.net/S...rials/index.php ). It executes find, and all the .dlls and image files are in the right place:
//ZAVE; a zombie defense game.
//Created by: REMOVED
//the headers, needed to use SDL, other images with SDL and strings
#include "SDL.h"
#include "SDL_image.h"
#include <string>
//header that stores all objects and constants
//#include "ZaveHeader.h"
#include <iostream>
using namespace std;
//the screen (play area) attributes&&&
const int SCREEN_WIDTH = 600;
const int SCREEN_HEIGHT = 600;
const int SCREEN_BPP = 32;
//the surfaces; used in displaying images on screen
SDL_Surface *zombie = NULL;
SDL_Surface *pickup = NULL;
SDL_Surface *player = NULL;
SDL_Surface *projectile = NULL;
SDL_Surface *screen = NULL;
//the event; used for key commmands & Xing out of prgm
SDL_Event event;
SDL_Surface *loadimage(std::string filename){
cout<< "loading images";
//the image that's loaded
SDL_Surface* loadedImage = NULL;
//the optimized surface that will be used
SDL_Surface* optimizedImage = NULL;
//load the image
loadedImage = IMG_Load(filename.c_str());
//if the image loaded
if(loadedImage != NULL){
//create optimized surface
optimizedImage = SDL_DisplayFormat(loadedImage);
//free the old surface for later use
SDL_FreeSurface(loadedImage);
//If the image was optimized
//if the optimizedImage was created correctly
if(optimizedImage != NULL){
//map the color key
Uint32 colorkey = SDL_MapRGB(optimizedImage->format, 0, 0xFF, 0xFF);
//set all pixels of color R 0, G 0xFF, B 0xFF to the background's color
SDL_SetColorKey(optimizedImage, SDL_SRCCOLORKEY, colorkey);
}
}
//return the optimizedImage created
return optimizedImage;
}
//applies the given image to the screen (surface)
//&&&NEEDS TO BE CHANGED TO ONLY PASS OBJECT'S RECT INSTEAD OF (X,Y)
void apply_surface(int x, int y, SDL_Surface* source, SDL_Surface* destination){
//create rectangle for holding x and y coordinates
SDL_Rect offset;
//store the x and y coordinates
offset.x = x;
offset.y = y;
//blit (draw image)
//2nd parameter is null because no sprite clipping is used
SDL_BlitSurface(source, NULL, destination, &offset);
}
//initializes everything, true if OK, false if error
bool init(){
//initializes all SDL subsystems, also checks for errors
if(SDL_Init(SDL_INIT_EVERYTHING) == -1){
return false;
}
//sets up screen
screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_SWSURFACE);
//return false if there was an error in creating the screen
if(screen == NULL){
return false;
}
//set the window caption
SDL_WM_SetCaption("ZWAVE!", NULL);
//return true if no problems
cout<< "got here";
return true;
}
//loads image files, returns false if problem, true if OK
bool load_files(){
//load the .jpg files for use
zombie = loadimage( "zombie.JPEG" );
pickup = loadimage( "health.JPEG" );
player = loadimage( "player.JPEG" );
projectile = loadimage( "projectile.JPEG" );
//return false if there was a problem loading the images
if((zombie == NULL) || (pickup = NULL) || (player = NULL) || (projectile = NULL)){
return false;
}
//return true if everything loaded OK
return true;
}
//cleans up when the program ends
void clean_up(){
//"free" the surface
SDL_FreeSurface(zombie);
SDL_FreeSurface(pickup);
SDL_FreeSurface(player);
SDL_FreeSurface(projectile);
//quit out of SDL
SDL_Quit();
}
int main( int argc, char* args[] ){
//quit flag
bool quit = false;
//initialize everything, return 1 if error
if(init() == false){
return 1;
}
//load the files, return 1 if error
if(load_files() == false){
return 1;
}
//while user hasn't quit...
while(quit == false){
//if an even happens
if(SDL_PollEvent(&event)){
//if the user has Xed out the window
if(event.type == SDL_QUIT){
//end the program
quit = true;
}
}
//fill the screen green
SDL_FillRect(screen, &screen->clip_rect, SDL_MapRGB(screen->format, 50, 205, 50));
//apply the surfaces
apply_surface( 0, 0, zombie, screen );
apply_surface( 100, 0, pickup, screen );
apply_surface( 200, 0, player, screen );
apply_surface( 300, 0, projectile, screen );
//update the screen, return 1 of error
if(SDL_Flip(screen) == -1){
return 1;
}
}
//clean up after quitting
clean_up();
return 0;
}
After compiling, this is the output displayed by VS 2008
Quote
'Zave.exe': Loaded 'C:\Users\USER\Desktop\Zave\Zave\Debug\Zave.exe', Symbols loaded.
'Zave.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll'
'Zave.exe': Loaded 'C:\Users\USER\Desktop\Zave\Zave\Debug\SDL.dll', Binary was not built with debug information.
'Zave.exe': Loaded 'C:\Windows\SysWOW64\advapi32.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\msvcrt.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\sechost.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\rpcrt4.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\sspicli.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\cryptbase.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\gdi32.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\user32.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\lpk.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\usp10.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\winmm.dll'
'Zave.exe': Loaded 'C:\Users\USER\Desktop\Zave\Zave\Debug\SDL_image.dll', Binary was not built with debug information.
'Zave.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc90.debugcrt_1fc8b3b9a1e18e3b_9.0.21022.8_none_96748342450f6aa2\msvcp90d.dll', Symbols loaded.
'Zave.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc90.debugcrt_1fc8b3b9a1e18e3b_9.0.21022.8_none_96748342450f6aa2\msvcr90d.dll', Symbols loaded.
'Zave.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4926_none_508ed732bcbc0e5a\msvcr90.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\imm32.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\msctf.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\ddraw.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\dciman32.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\setupapi.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\cfgmgr32.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\oleaut32.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\ole32.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\devobj.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\dwmapi.dll'
'Zave.exe': Unloaded 'C:\Windows\SysWOW64\ddraw.dll'
'Zave.exe': Unloaded 'C:\Windows\SysWOW64\dwmapi.dll'
'Zave.exe': Unloaded 'C:\Windows\SysWOW64\setupapi.dll'
'Zave.exe': Unloaded 'C:\Windows\SysWOW64\devobj.dll'
'Zave.exe': Unloaded 'C:\Windows\SysWOW64\oleaut32.dll'
'Zave.exe': Unloaded 'C:\Windows\SysWOW64\ole32.dll'
'Zave.exe': Unloaded 'C:\Windows\SysWOW64\cfgmgr32.dll'
'Zave.exe': Unloaded 'C:\Windows\SysWOW64\dciman32.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\uxtheme.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\dwmapi.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\KBDUS.DLL'
'Zave.exe': Unloaded 'C:\Windows\SysWOW64\KBDUS.DLL'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\KBDUS.DLL'
'Zave.exe': Unloaded 'C:\Windows\SysWOW64\KBDUS.DLL'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\dsound.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\ole32.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\powrprof.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\setupapi.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\cfgmgr32.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\oleaut32.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\devobj.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\dinput.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\hid.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\wintrust.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\crypt32.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\msasn1.dll'
The thread 'Win32 Thread' (0x18fc) has exited with code 1 (0x1).
The thread 'Win32 Thread' (0x196c) has exited with code 1 (0x1).
The program '[6236] Zave.exe: Native' has exited with code 1 (0x1).
'Zave.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll'
'Zave.exe': Loaded 'C:\Users\USER\Desktop\Zave\Zave\Debug\SDL.dll', Binary was not built with debug information.
'Zave.exe': Loaded 'C:\Windows\SysWOW64\advapi32.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\msvcrt.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\sechost.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\rpcrt4.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\sspicli.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\cryptbase.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\gdi32.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\user32.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\lpk.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\usp10.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\winmm.dll'
'Zave.exe': Loaded 'C:\Users\USER\Desktop\Zave\Zave\Debug\SDL_image.dll', Binary was not built with debug information.
'Zave.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc90.debugcrt_1fc8b3b9a1e18e3b_9.0.21022.8_none_96748342450f6aa2\msvcp90d.dll', Symbols loaded.
'Zave.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc90.debugcrt_1fc8b3b9a1e18e3b_9.0.21022.8_none_96748342450f6aa2\msvcr90d.dll', Symbols loaded.
'Zave.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4926_none_508ed732bcbc0e5a\msvcr90.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\imm32.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\msctf.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\ddraw.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\dciman32.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\setupapi.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\cfgmgr32.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\oleaut32.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\ole32.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\devobj.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\dwmapi.dll'
'Zave.exe': Unloaded 'C:\Windows\SysWOW64\ddraw.dll'
'Zave.exe': Unloaded 'C:\Windows\SysWOW64\dwmapi.dll'
'Zave.exe': Unloaded 'C:\Windows\SysWOW64\setupapi.dll'
'Zave.exe': Unloaded 'C:\Windows\SysWOW64\devobj.dll'
'Zave.exe': Unloaded 'C:\Windows\SysWOW64\oleaut32.dll'
'Zave.exe': Unloaded 'C:\Windows\SysWOW64\ole32.dll'
'Zave.exe': Unloaded 'C:\Windows\SysWOW64\cfgmgr32.dll'
'Zave.exe': Unloaded 'C:\Windows\SysWOW64\dciman32.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\uxtheme.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\dwmapi.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\KBDUS.DLL'
'Zave.exe': Unloaded 'C:\Windows\SysWOW64\KBDUS.DLL'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\KBDUS.DLL'
'Zave.exe': Unloaded 'C:\Windows\SysWOW64\KBDUS.DLL'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\dsound.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\ole32.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\powrprof.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\setupapi.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\cfgmgr32.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\oleaut32.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\devobj.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\dinput.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\hid.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\wintrust.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\crypt32.dll'
'Zave.exe': Loaded 'C:\Windows\SysWOW64\msasn1.dll'
The thread 'Win32 Thread' (0x18fc) has exited with code 1 (0x1).
The thread 'Win32 Thread' (0x196c) has exited with code 1 (0x1).
The program '[6236] Zave.exe: Native' has exited with code 1 (0x1).
any suggestions? thanks guys

New Topic/Question
Reply



MultiQuote




|