JNR
laFinal.cpp
1 /*
2 
3 Jump'n'Run Engine
4 http://www.atanaslaskov.com/jnr/
5 
6 BSD LICENSE
7 Copyright (c) 2007-2013, Atanas Laskov
8 All rights reserved.
9 
10 Redistribution and use in source and binary forms, with or without
11 modification, are permitted provided that the following conditions are met:
12 1. Redistributions of source code must retain the above copyright notice,
13 this list of conditions and the following disclaimer.
14 2. Redistributions in binary form must reproduce the above copyright notice,
15 this list of conditions and the following disclaimer in the documentation
16 and/or other materials provided with the distribution.
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 DISCLAIMED. IN NO EVENT SHALL ATANAS LASKOV BE LIABLE FOR ANY
21 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
28 */
29 //
30 // FILE: laFinal.cpp
31 //
32 // Copyright (C) 2007-2013 Atanas Laskov, <latanas@gmail.com>
33 //
34 #include "stdafx.h"
35 #include "Core-Level-JR.h"
36 
37 laFinal::laFinal(void)
38 {
39  _ttFinishFx.parameters(4);
40  _ttFinishFx.enable(M_FALSE);
41  _ttFinishFx.reset();
42 
43  _pFinishSound = NULL;
44 }
45 
46 laFinal::~laFinal(void)
47 {
48 }
49 
50 void laFinal::animate(laTimer &t)
51 {
52  ERRORLEVEL_BEGIN;
53  laPlayer* p = getLevelObject()->getPlayer();
54 
55  /*if(_pFinishSound==NULL)
56  _pFinishSound = laSystemIntegrator::getSound()->soundCreate("sound\\final2.mp3");*/
57 
58  if(_ttFinishFx.isEnabled() && (_ttFinishFx.timeRemaining()<=_ttFinishFx.getElapseTime()/3) )
59  {
60  _ttFinishFx.enable(M_FALSE);
61 
62  getLevelObject()->forceCompleted();
63  p->move(0);
64  }
65 
66  if(getLevelObject()->isCompleted() && (!_ttFinishFx.isEnabled()))
67  {
68  //p->ctlJump();
69  }
70 
71  if(_ttFinishFx.isEnabled())
72  getLevelObject()->zoom( getLevelObject()->zoom() + 0.5*t.delta());
73 
74  _ttFinishFx.animate(t);
75  laCollectable::animate(t);
76 
77  ERRORLEVEL_END;
78 }
79 
80 M_BOOL laFinal::_collect_actions()
81 {
82  laPlayer* p = (laPlayer*)( getLevelObject()->getPlayer() );
83  p->enableBattleZoom(M_FALSE);
84 
85  _ttFinishFx.enable(M_TRUE);
86 
87  return laCollectable::_collect_actions();
88 
89  //_pFinishSound->play();
90 }
91 
92 void laFinal::drawInterface(laRenderer *r, laPoint3 ptBasePos)
93 {
94  laSettings* ps = laSystemIntegrator::getSettings();
95  double w = ps->graphics_resolution_w;
96  double h = ps->graphics_resolution_h;
97  double alpha;
98 
99  if( getLevelObject()->isCompleted() || _ttFinishFx.isEnabled())
100  {
101  alpha = 255-255*( _ttFinishFx.reminder() /*_ttFinishFx.timeRemaining()/_ttFinishFx.getElapseTime()*/ );
102 
103  r->modeTexture(M_FALSE);
104  r->styleSet(laColor(220,210,210, (unsigned char)alpha));
105  r->drawRect(laPoint3(), laPoint3(ps->graphics_resolution_w, ps->graphics_resolution_h), laPoint2(), laPoint2());
106 
107  r->font("deco")->ctlAlignH(M_AC);
108  r->font("deco")->ctlSize(70);
109 
110  r->styleSet(laColor(255,255,255,255));
111  r->font("deco")->draw(ptBasePos+laPoint3(w/2, h/3), "Level Completed");
112 
113  if( !_ttFinishFx.isEnabled())
114  {
115  r->styleSet(laColor(255,255,255,200));
116  r->font("deco")->ctlAlignH(M_AC);
117  r->font("deco")->ctlSize(25);
118  r->font("deco")->draw(ptBasePos+laPoint3(w/2, h/3+80), "press enter to continue...");
119  }
120  }
121 
122  laCollectable::drawInterface(r, ptBasePos);
123 }
laFont * font(char *strName)
Get a font renderer.
Definition: laRenderer.h:192
virtual void modeTexture(M_BOOL bOn)=0
Enable/disable texturing.
Playable Character.
Definition: laPlayer.h:46
2D Point
Definition: laPoint_novec.h:41
Game Settings.
Definition: laSettings.h:38
#define M_AC
Text align center.
Virtual interface for the Engine graphics renderer.
Definition: laRenderer.h:98