[6555] | 1 | /* |
---|
| 2 | orxonox - the future of 3D-vertical-scrollers |
---|
| 3 | |
---|
| 4 | Copyright (C) 2004 orx |
---|
| 5 | |
---|
| 6 | This program is free software; you can redistribute it and/or modify |
---|
| 7 | it under the terms of the GNU General Public License as published by |
---|
| 8 | the Free Software Foundation; either version 2, or (at your option) |
---|
| 9 | any later version. |
---|
| 10 | |
---|
| 11 | ### File Specific: |
---|
| 12 | main-programmer: David Hasenfratz, Stefan Lienhard |
---|
[6557] | 13 | co-programmer: |
---|
[6555] | 14 | */ |
---|
| 15 | |
---|
| 16 | #include "movie_loader.h" |
---|
[6576] | 17 | |
---|
[6570] | 18 | #include "movie_player.h" |
---|
[6576] | 19 | #include "load_param.h" |
---|
[6555] | 20 | #include "resource_manager.h" |
---|
| 21 | |
---|
[6576] | 22 | |
---|
[6555] | 23 | using namespace std; |
---|
| 24 | |
---|
| 25 | |
---|
[6576] | 26 | MovieLoader::MovieLoader(const TiXmlElement* root) |
---|
[6555] | 27 | { |
---|
| 28 | this->setClassID(CL_MOVIE_LOADER, "MovieLoader"); |
---|
[6576] | 29 | |
---|
| 30 | movie_player = new MoviePlayer(); |
---|
| 31 | this->loadParams(root); |
---|
[6555] | 32 | } |
---|
| 33 | |
---|
| 34 | MovieLoader::~MovieLoader() |
---|
| 35 | { |
---|
| 36 | PRINTF(4)("Deleted MoviePlayer\n"); |
---|
| 37 | } |
---|
| 38 | |
---|
| 39 | |
---|
| 40 | |
---|
| 41 | void MovieLoader::loadParams(const TiXmlElement* root) |
---|
| 42 | { |
---|
[6576] | 43 | StoryEntity::loadParams(root); |
---|
[6555] | 44 | |
---|
[6576] | 45 | LoadParam(root, "name", this, MovieLoader, loadMovie); |
---|
[6555] | 46 | } |
---|
| 47 | |
---|
[6576] | 48 | void MovieLoader::loadMovie(const char* filename) |
---|
| 49 | { |
---|
| 50 | movie_player->loadMovie(filename); |
---|
[6555] | 51 | |
---|
[6576] | 52 | PRINTF(0)("loaded Movie %s", filename); |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | |
---|
[6555] | 56 | ErrorMessage MovieLoader::init() |
---|
| 57 | { |
---|
| 58 | |
---|
| 59 | } |
---|
| 60 | |
---|
| 61 | |
---|
| 62 | ErrorMessage MovieLoader::loadData() |
---|
| 63 | { |
---|
| 64 | |
---|
| 65 | } |
---|
| 66 | |
---|
| 67 | |
---|
| 68 | ErrorMessage MovieLoader::unloadData() |
---|
| 69 | { |
---|
| 70 | |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | bool MovieLoader::start() |
---|
| 74 | { |
---|
[6574] | 75 | this->isRunning = true; |
---|
[6555] | 76 | |
---|
[6574] | 77 | this->run(); |
---|
[6555] | 78 | } |
---|
| 79 | |
---|
| 80 | bool MovieLoader::stop() |
---|
| 81 | { |
---|
[6574] | 82 | this->isRunning = false; |
---|
[6555] | 83 | } |
---|
| 84 | |
---|
[6574] | 85 | bool MovieLoader::pause() { } |
---|
| 86 | bool MovieLoader::resume() { } |
---|
[6555] | 87 | |
---|
| 88 | void MovieLoader::run() |
---|
| 89 | { |
---|
[6567] | 90 | // first timestamp for t = 0 |
---|
| 91 | this->lastFrame = SDL_GetTicks (); |
---|
| 92 | |
---|
[6562] | 93 | while( this->isRunning) |
---|
| 94 | { |
---|
[6555] | 95 | |
---|
[6562] | 96 | this->tick(); |
---|
| 97 | |
---|
[6576] | 98 | //movie_player->draw(); |
---|
[6562] | 99 | } |
---|
[6555] | 100 | } |
---|
[6557] | 101 | |
---|
| 102 | void MovieLoader::tick() |
---|
| 103 | { |
---|
[6567] | 104 | // get timestamp |
---|
[6574] | 105 | currentFrame = SDL_GetTicks(); |
---|
[6557] | 106 | |
---|
[6567] | 107 | // calculate time difference in milliseconds (Uint32) |
---|
| 108 | this->dt = currentFrame - this->lastFrame; |
---|
| 109 | // calculate time difference in seconds (float) |
---|
[6570] | 110 | this->dts = (float)this->dt / 1000.0f; |
---|
[6567] | 111 | |
---|
| 112 | movie_player->tick(dts); |
---|
| 113 | |
---|
| 114 | this->lastFrame = currentFrame; |
---|
[6557] | 115 | } |
---|