File: ecran.cc

package info (click to toggle)
ri-li 2.0.1%2Bds-10
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 41,980 kB
  • sloc: cpp: 4,493; sh: 785; makefile: 97
file content (144 lines) | stat: -rw-r--r-- 3,532 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
//      (_||_/
//      (    )       Classe Ecran
//     ( o  0 )
//-OOO--(_)---OOO---------------------------------------
//                   Copyright (C) 2006 By Dominique Roux-Serret
// .OOOo      oOOO.  roux-serret@ifrance.com
//-(   )------(   )---------------------------------------
//  ( (        ) /   Le 12/01/2006
//   (_)      (_/

//    This program is free software; you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation; either version 2 or version 3 of the License.

//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY 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 License along
//    with this program; if not, write to the Free Software Foundation, Inc.,
//    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

#include <iostream>
using namespace std;
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "preference.h"
#include "sprite.h"
#include "ecran.h"

/*** Variables globales ***/
/**************************/
extern Sprite *Sprites;
extern sPreference Pref;

/*** Constructeur ***/
/********************/
Ecran::Ecran(void) : N(0), NVie(0), Score(-1)
{ }

Ecran::~Ecran(void)
{ }

/*** Affiche un Sprite ***/
/*************************/
void Ecran::Affiche(e_Sprite NumSpr,int Num,int x,int y)
{
  B[N].NumSpr=NumSpr;
  B[N].Num=Num;
  B[N].x=x;
  B[N].y=y;
  N++;

  Sprites[NumSpr].Affiche(x,y,Num);
}

/*** Affiche un cable ***/
/************************/
void Ecran::AfficheCable(int dx,int dy,int fx,int fy)
{
  // Affiche la corde
  Sprites[corde].AfficheCorde(dx,dy,fx,fy);
  
  // Sauve la position du cable pour l'effacer
  B[N].NumSpr=corde;
  B[N].Num=0;
  B[N].x=dx;
  B[N].y=dy;
  B[N].fx=fx;
  B[N].fy=fy;
  N++;
}

/*** Affiche un text ***/
/***********************/
void Ecran::Affiche_Text(e_Sprite Text,int x,int y)
{
  B[N].NumSpr=Text;
  B[N].Num=0;
  B[N].x=x;
  B[N].y=y;
  N++;

  Sprites[Text].Affiche(x,y,0);
}

/*** Affiche les options du jeu ***/
/**********************************/
void Ecran::AfficheOptions(int NV,int NScore)
{
  int x,y;

  if(NScore!=Score) { // Gre l'affichage des scores
    if(Score!=-1) EffaceChiffre(740,215,Score);
    Score=NScore;
    AfficheChiffre(740,215,Score);
  }

  if(NV>10) NV=10; // Evite un dpassement de l'affichage

  while(NVie>NV) { // Si doit effacer des vies
    x=(NVie-1)%2;
    x=x*44+38+LT*D_Case;
    y=(NVie-1)/2;
    y=384+y*46;
    Sprites[logo_vie].Efface(x,y,0,Sprites[fjeu].Image[0]);
    NVie--;
  }

  while(NVie<NV) { // Si doit afficher des vies
    x=NVie%2;
    x=x*44+38+LT*D_Case;
    y=NVie/2;
    y=384+y*46;
    Sprites[logo_vie].Affiche(x,y,0);
    NVie++;
  }
}

/*** Efface les sprites ***/
/**************************/
void Ecran::Efface(e_Sprite NumSp)
{
  int i;
  
  for(i=0;i<N;i++) {
    if(B[i].NumSpr==corde) Sprites[B[i].NumSpr].EffaceCarre(B[i].x,B[i].y,B[i].fx,B[i].fy,
							    Sprites[NumSp].Image[0]); 
    else Sprites[B[i].NumSpr].Efface(B[i].x,B[i].y,B[i].Num,Sprites[NumSp].Image[0]);
  }
  N=0;
}

/*** Efface l'ecran avec l'image de fond ***/
/*******************************************/
void Ecran::Cls(e_Sprite NumSp)
{
  Sprites[NumSp].Affiche(Sprites[NumSp].Dim[0].L/2,Sprites[NumSp].Dim[0].H/2,0);
  N=0;
  NVie=0;
  Score=-1;
}