1 /*
2 * bigring.c - big ring
3 * Copyright (C) 2010 Alexandre Martins <alemartf(at)gmail(dot)com>
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 along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #include "bigring.h"
21 #include "../../core/util.h"
22 #include "../../core/soundfactory.h"
23 #include "../../scenes/level.h"
24 #include "../../scenes/quest.h"
25
26 /* bigring class */
27 typedef struct bigring_t bigring_t;
28 struct bigring_t {
29 item_t item; /* base class */
30 };
31
32 static void bigring_init(item_t *item);
33 static void bigring_release(item_t* item);
34 static void bigring_update(item_t* item, player_t** team, int team_size, brick_list_t* brick_list, item_list_t* item_list, enemy_list_t* enemy_list);
35 static void bigring_render(item_t* item, v2d_t camera_position);
36
37
38
39 /* public methods */
bigring_create()40 item_t* bigring_create()
41 {
42 item_t *item = mallocx(sizeof(bigring_t));
43
44 item->init = bigring_init;
45 item->release = bigring_release;
46 item->update = bigring_update;
47 item->render = bigring_render;
48
49 return item;
50 }
51
52
53 /* private methods */
bigring_init(item_t * item)54 void bigring_init(item_t *item)
55 {
56 item->obstacle = FALSE;
57 item->bring_to_back = FALSE;
58 item->preserve = TRUE;
59 item->actor = actor_create();
60
61 actor_change_animation(item->actor, sprite_get_animation("SD_BIGRING", 0));
62 }
63
64
65
bigring_release(item_t * item)66 void bigring_release(item_t* item)
67 {
68 actor_destroy(item->actor);
69 }
70
71
72
bigring_update(item_t * item,player_t ** team,int team_size,brick_list_t * brick_list,item_list_t * item_list,enemy_list_t * enemy_list)73 void bigring_update(item_t* item, player_t** team, int team_size, brick_list_t* brick_list, item_list_t* item_list, enemy_list_t* enemy_list)
74 {
75 int i;
76
77 for(i=0; i<team_size; i++) {
78 player_t *player = team[i];
79 if(!player->dying && actor_collision(player->actor, item->actor)) {
80 item->state = IS_DEAD;
81 player_set_rings( player_get_rings() + 50 );
82 level_add_to_secret_bonus(5000);
83 sound_play( soundfactory_get("big ring") );
84 level_call_dialogbox("$BONUSMSG_TITLE", "$BONUSMSG_TEXT");
85 quest_setvalue(QUESTVALUE_BIGRINGS, quest_getvalue(QUESTVALUE_BIGRINGS) + 1);
86 }
87 }
88 }
89
90
bigring_render(item_t * item,v2d_t camera_position)91 void bigring_render(item_t* item, v2d_t camera_position)
92 {
93 actor_render(item->actor, camera_position);
94 }
95
96