?? cargo.cpp
字號(hào):
/*Copyright (C) 2003 Parallel RealitiesThis program is free software; you can redistribute it and/ormodify it under the terms of the GNU General Public Licenseas published by the Free Software Foundation; either version 2of the License, or (at your option) any later version.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; if not, write to the Free SoftwareFoundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.*/#include "cargo.h"void initCargo(){ for (int i = 0 ; i < MAX_CARGO ; i++) { cargo[i].active = 0; cargo[i].owner = NULL; }}/** I think you all know what this does by now! ;)*/int getCargo(){ for (int i = 0 ; i < MAX_CARGO ; i++) { if (cargo[i].active == 0) return i; } return -1;}object *addCargo(object *owner, int cargoType){ int index = getCargo(); if (index == -1) return NULL; cargo[index].active = 1; cargo[index].owner = owner; cargo[index].x = owner->x; cargo[index].y = owner->y; cargo[index].dx = 0; cargo[index].dy = 0; cargo[index].collectType = cargoType; cargo[index].image[0] = graphics.shape[32]; if (cargoType == P_PHOEBE) cargo[index].image[0] = graphics.shipShape[20]; return &cargo[index];}void becomeCollectable(int i){ if (cargo[i].collectType != P_PHOEBE) { addCollectable(cargo[i].x, cargo[i].y, cargo[i].collectType, 1, 600); } else { enemy[FR_PHOEBE].active = 1; enemy[FR_PHOEBE].x = cargo[i].x; enemy[FR_PHOEBE].y = cargo[i].y; setRadioMessage(FACE_PHOEBE, "Thanks!! Watch out, WEAPCO! Phoebe's loose and she's ANGRY!!!", 1); } cargo[i].active = 0;}void doCargo(){ float dx, dy, chainX, chainY; for (int i = 0 ; i < MAX_CARGO ; i++) { if (cargo[i].active) { if (!cargo[i].owner->active) { becomeCollectable(i); continue; } graphics.blit(cargo[i].image[0], (int)cargo[i].x, (int)cargo[i].y); cargo[i].x += engine.ssx; cargo[i].y += engine.ssy; Math::limitFloat(&cargo[i].x, cargo[i].owner->x - 50, cargo[i].owner->x + 50); Math::limitFloat(&cargo[i].y, cargo[i].owner->y - 50, cargo[i].owner->y + 50); dx = (cargo[i].x - cargo[i].owner->x) / 10; dy = (cargo[i].y - cargo[i].owner->y) / 10; chainX = cargo[i].x - cargo[i].dx; chainY = cargo[i].y - cargo[i].dy; // draw the chain link line for (int j = 0 ; j < 10 ; j++) { graphics.blit(graphics.shape[30], (int)chainX, (int)chainY); chainX -= dx; chainY -= dy; } } }}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -