Skip to content

Commit

Permalink
SDL rendering unusual fast behavior controlled
Browse files Browse the repository at this point in the history
  • Loading branch information
lpsandaruwan committed Apr 3, 2017
1 parent d5579a5 commit 47f6d7f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ CPackSourceConfig.cmake
_site
Gemfile
Gemfile.lock
install_manifest.txt
_CPack_Packages/
savior_ship-0.1.1-1.x86_64.deb
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ ELSE()
INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIRS} ${SDL2IMAGE_INCLUDE_DIRS})
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${SDL2_LIBRARIES} ${SDL2IMAGE_LIBRARIES} ${SDL2MIXER_LIBRARIES} ${SDL2TTF_LIBRARIES})

SET(VERSION "0.1.0")
SET(VERSION "0.1.1")
SET(CPACK_PACKAGE_VERSION ${VERSION})
SET(CPACK_GENERATOR "DEB")
SET(CPACK_PACKAGE_NAME "savior_ship")
Expand Down
Binary file removed assets/graphics/background.jpg
Binary file not shown.
Binary file added assets/graphics/background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 6 additions & 2 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,14 @@ bool initialize()
return status;
}

// load all the images/audio files
bool prepareMediaFiles()
{
bool startFlag = false;
bool status = true;

// load background media
if(!backgroundWrapper.loadGraphicsFile(globalRenderer, "./assets/graphics/background.jpg"))
if(!backgroundWrapper.loadGraphicsFile(globalRenderer, "./assets/graphics/background.png"))
{
std::cout << "Failed to load background image " << std::endl;
status = false;
Expand Down Expand Up @@ -237,6 +238,7 @@ bool prepareMediaFiles()
return status;
}

// generate a random integer number between two integers
int generateRandomNumber(int min, int max)
{
std::random_device randomDevice;
Expand All @@ -246,12 +248,14 @@ int generateRandomNumber(int min, int max)
return distr(eng);
}

// used to display destroyed object image for a while
void delayDestroyObject(Object* destroyedObject)
{
usleep(100000);
destroyedObject->inProgress = false;
}

// modify appearing places enemy objects offsets
void modifyRenderObjectList(Object* renderList[], Object* objectList[], SDL_Event* e)
{
while(true)
Expand Down Expand Up @@ -551,7 +555,7 @@ int main(int argc, char* args[])

// update window
SDL_RenderPresent(globalRenderer);
SDL_Delay(0);
SDL_Delay(10);
}
}
}
Expand Down

0 comments on commit 47f6d7f

Please sign in to comment.