~ubuntu-branches/ubuntu/lucid/balder2d/lucid

« back to all changes in this revision

Viewing changes to src/probefactory.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Bjørn Hansen
  • Date: 2006-10-14 15:33:42 UTC
  • Revision ID: james.westby@ubuntu.com-20061014153342-un0jglolcs01gcow
Tags: upstream-1.0~rc1
Import upstream version 1.0~rc1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright (C) 2004 by Bjorn Hansen                                    *
 
3
 *   holomorph@users.sourceforge.net                                       *
 
4
 *                                                                         *
 
5
 *   This program is free software; you can redistribute it and/or modify  *
 
6
 *   it under the terms of the GNU General Public License as published by  *
 
7
 *   the Free Software Foundation; either version 2 of the License, or     *
 
8
 *   (at your option) any later version.                                   *
 
9
 *                                                                         *
 
10
 *   This program is distributed in the hope that it will be useful,       *
 
11
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 
12
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 
13
 *   GNU General Public License for more details.                          *
 
14
 *                                                                         *
 
15
 *   You should have received a copy of the GNU General Public License     *
 
16
 *   along with this program; if not, write to the                         *
 
17
 *   Free Software Foundation, Inc.,                                       *
 
18
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 
19
 ***************************************************************************/
 
20
 
 
21
#include <SDL/SDL.h>
 
22
#include <SDL/SDL_image.h>
 
23
#include "../include/probefactory.h" // class's header file
 
24
#include "../include/renderer.h"
 
25
#include "../include/soundmanager.h"
 
26
#include "../include/probe.h"
 
27
 
 
28
using namespace Balder;
 
29
 
 
30
// class constructor
 
31
ProbeFactory::ProbeFactory(Renderer* render, SoundManager* sound)
 
32
{
 
33
    sprite = IMG_Load("probe.png");
 
34
    if (sprite == 0)
 
35
    {
 
36
        throw "could not load Probe sprite!";
 
37
    }
 
38
    render->RegisterSpriteType("probe", sprite);
 
39
    // now load the sounds
 
40
    sound->LoadSoundType("fire", "sounds/fire.ogg");
 
41
    sound->LoadSoundType("probe bounce", "sounds/probe_bounce.ogg");
 
42
    sound->LoadSoundType("probe collide", "sounds/probe_collide.ogg");
 
43
    sound->LoadSoundType("probe hit", "sounds/probe_hit.ogg");
 
44
    sound->LoadSoundType("probe destroyed", "sounds/probe_destroyed.ogg");
 
45
    sound->LoadSoundType("probe stick", "sounds/probe_stick.ogg");
 
46
    sound->LoadSoundType("probe push", "sounds/probe_push.ogg");
 
47
    sound->LoadSoundType("shields up", "sounds/probe_shields.ogg");
 
48
}
 
49
 
 
50
// class destructor
 
51
ProbeFactory::~ProbeFactory()
 
52
{
 
53
        SDL_FreeSurface(sprite);
 
54
}
 
55
 
 
56
/**
 
57
  * creates a Probe */
 
58
Probe* ProbeFactory::CreateProbe(GameManager* gm, double x_position, double y_position, 
 
59
    double x_velocity, double y_velocity, bool stuck, probe_color color, player_id pid)
 
60
{
 
61
    return new Probe(gm, x_position, y_position, x_velocity, y_velocity, stuck, color, pid);
 
62
}