bonjour, bonsoir
je vous explique mon petit souci, j' ai pour projet de reproduire le jeux "the binding of isaac" (en moin bien , évidement) et pour cela je dois creer les tirs de mon personnage.
or dans le code que vous allez voir , le programme me crée un cercle puis plus rien , ce qui est normale vous allez me dire mais je ne vois pas comment faire pour changer ca.
on m'a parlé de la fonction std::vector<> mais je ne sais pas comment elle fonctionne (et nous ne l'avons pas vu) j'ai ensuite pensé a faire un teste en creant plusieurs boules puis suivant la valeur d un entier , je cree une boule, le probleme , c est : elle est de quel type ? puisque je doit la declarer dans la structure .... bref je vous laisse le code et si une quelconque aide peut m'etre apporté je suis preneur.


derniere précision, ma bibliotheque graphique est : grapic mais elle utilise la SDL donc dans le fonctionnement c'est plus ou moin la meme chose.


Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
#include <iostream>
#include <Grapic.h>
const int Dimw =500;
using namespace grapic;
struct Complex{
float x,y;
};
 
Complex make_complex(float x,float y)
{
    Complex c;
    c.x=x;
    c.y=y;
    return c;
}
float rad_to_deg(float a)
{
    return(a*360.0)/(2*M_PI);
}
float deg_to_rad(float a)
{
    return (a*2*M_PI)/360.0;
}
 
Complex make_complex_exp(float r,float theta_deg)
{
    Complex c;
    float a = deg_to_rad(theta_deg);
 
    c.x=r*cos(a);
    c.y=r*sin(a);
    return c;
}
 
Complex operator+(Complex a,Complex b)
{
    Complex c;
    c.x=a.x+b.x;
    c.y=a.y+b.y;
    return c;
}
 
Complex operator-(Complex a,Complex b)
{
    Complex c;
    c.x=a.x-b.x;
    c.y=a.y-b.y;
    return c;
}
 
Complex operator*(Complex a,float lambda)
{
    return(make_complex(a.x*lambda,a.y*lambda));
}
 
Complex scale (Complex a,float cx,float cy, float lambda)
{
    Complex res;
    Complex tr=make_complex(cx,cy);
    res=((a-tr)*lambda+tr);
    return res;
}
 
Complex operator*(Complex a,Complex b)
{
    return (make_complex(a.x*b.x-a.y*b.y,a.x*b.y+a.y*b.x));
}
 
Complex Rotate(Complex p,float cx,float cy,float theta_deg)
{
    Complex res,r,tr;
    r=make_complex_exp(1,theta_deg);
    tr=make_complex(cx,cy);
    res=((p-tr)*r)+tr;
    return res;
}
 
struct boule{
Complex c;
int bl;
};
void Draw (boule B){
 
circleFill(B.c.x,B.c.y, 10);
 
}
void init (boule &B) {
 B.c=make_complex(Dimw/2,Dimw/2);
 
if (isKeyPressed (SDLK_SPACE)){
    Draw(B);
}
}
 
 
 
void update (boule &B){
 B.c.x =B.c.x +0.8;
 
}
 
int main (int, char**){
 
 
 bool stop=false;
    winInit("projet", 800, Dimw);
    boule B;
    init (B);
 
 setKeyRepeatMode(true);
 while( !stop )
 {
 winClear();
 //Draw(B);
 update (B);
  backgroundColor(100,100,100,85);
//100,255,50,85);...........................vert
 stop = winDisplay();
 }
 winQuit();
 return 0;
}