Aller directement au contenu

Problème C

Avatar de KikooDX
Membre
Niveau 1 (38)
Niv. 1
Posté le 3 Décembre à 13:45

Ça marche pas welp

1
2
3
4
5
6
7
8
9
def void main():
    hellow();
    nevor();

def hello():
    print("Hello, Worrrld!");

def never():
    print("Never gonna give you up");

:D merci lol ahah :D

Avatar de cake
Membre
Niveau 0 (4)
Niv. 0

C'est pas vraiment du C enfaite

Avatar de _pedroBzh
Membre
Niveau 0 (27)
Niv. 0

lol c'est un mélange chelou entre la sintaxe de python et le point virgule du C/C++


coucou je suis la...

pensés suicidaires: 90%

Avatar de _pedroBzh
Membre
Niveau 0 (27)
Niv. 0
  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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
extern "C"{
    #include <gint/display.h>
    #include <gint/keyboard.h>
    //#include <gint/std/string.h>
}
#define MAP_X 250
#define BLOCKS_LEN 17
#define CRAFTS 2
using namespace std;

int sx = 0;
int x = 100;
int y = 30;
extern bopti_image_t img_tilemap;
extern bopti_image_t img_craft;
int8_t game_map[MAP_X+1][7] = {0};
int opt = GETKEY_DEFAULT | GETKEY_REP_ARROWS | GETKEY_MENU;
int optd = GETKEY_DEFAULT | GETKEY_MENU;
int timeout = 1;
int key;
int rwalk =0;
int can_move = 1;
int dir = 1;
int vdir;
int sele = 2;
int vas = 0;
int sinv = 3;
int inv[BLOCKS_LEN+1] = {0};
int btmp = sinv;
int selecoll = 0;
int rockminer_interval = 1000;
int craftdata[][6] = {{5,1,4,2,15,1},{3,2,15,4,0,0}};
int s = 0;

int isCollide(int num){
    if(num==0){return 1;}
    else if(num==3){return 1;}
    else if(num==14){return 1;}
    else if(num==15){return 1;}
    else if(num==16){return 1;}
    else{return 0;}
}

int isMultipleof5 (int n)
{
    while ( n > 0 )
        n = n - 5;

    if ( n == 0 )
        return 1;

    return 0;
}

void PrintSblock(int num,int x,int y){
    dsubimage(x*10, y*10+4 ,&img_tilemap,num*10,10,10, 10, DIMAGE_NONE);
}

void PrintMap(){
    int cx = MAP_X;
    int cy = 6;
    dsubimage(116, 0 ,&img_tilemap,sinv*10,0,10, 10, DIMAGE_NONE);
    dhline(12,C_BLACK);
    dprint(96, 0, C_BLACK, "%d", inv[sinv]);
    while(cx>0){
    cy = 6;
        while(cy>0){
            dsubimage(cx*10-sx, cy*10+4 ,&img_tilemap,game_map[cx][cy]*10,0,10, 10, DIMAGE_NONE);
            /*if(game_map[cx][cy]==2&&game_map[cx][cy]>1&&game_map[cx][cy]<MAP_X){
                if(game_map[cx-1][cy]==2&&game_map[cx+1][cy]==2){PrintSblock(4,cx,cy);}
                if(game_map[cx-1][cy]!=2&&game_map[cx+1][cy]==2){PrintSblock(3,cx,cy);}
                if(game_map[cx-1][cy]==2&&game_map[cx+1][cy]!=2){PrintSblock(5,cx,cy);}
            }*/
            cy--;
        }
        cx--;
    }
    if(dir==0){dsubimage(x-sx, y+4 ,&img_tilemap,5*10,20,10, 10, DIMAGE_NONE);}
    if(dir==1){dsubimage(x-sx, y+4 ,&img_tilemap,4*10,20,10, 10, DIMAGE_NONE);}
    if(vas==0&& (keydown(KEY_VARS) || keydown(KEY_SQUARE))){
        if(sele==1){dsubimage(x+10-sx, y+4 ,&img_tilemap,0,20,10, 10, DIMAGE_NONE);}
        if(sele==2){dsubimage(x-sx, y+4+10 ,&img_tilemap,0,20,10, 10, DIMAGE_NONE);}
        if(sele==3){dsubimage(x-10-sx, y+4 ,&img_tilemap,0,20,10, 10, DIMAGE_NONE);}
        if(sele==0){dsubimage(x-sx, y+4-10 ,&img_tilemap,0,20,10, 10, DIMAGE_NONE);}
    }
    if(vas==1){
        if(sele==1){dsubimage(x+10-sx, y+4 ,&img_tilemap,10,20,10, 10, DIMAGE_NONE);}
        if(sele==2){dsubimage(x-sx, y+4+10 ,&img_tilemap,10,20,10, 10, DIMAGE_NONE);}
        if(sele==3){dsubimage(x-10-sx, y+4 ,&img_tilemap,10,20,10, 10, DIMAGE_NONE);}
        if(sele==0){dsubimage(x-sx, y+4-10 ,&img_tilemap,10,20,10, 10, DIMAGE_NONE);}
    }
}

int craft(int item){
    if(craftdata[item][3]<=inv[craftdata[item][2]] && craftdata[item][5]<=inv[craftdata[item][4]]){
        inv[craftdata[item][2]] = inv[craftdata[item][2]] - craftdata[item][3];
        inv[craftdata[item][4]] = inv[craftdata[item][4]] - craftdata[item][5];
        inv[craftdata[item][0]] = inv[craftdata[item][0]] + craftdata[item][1];
        return 1;
    }
    else{
        return 0;
    }
}

void craftmenu(){
    int s = 0;
    while(1){
        dclear(C_WHITE);
        for(int i=0;i<CRAFTS;i++) {
            dsubimage(0,i*16,&img_craft,0,0,128,16,DIMAGE_NONE); // template
            if(s==i){dsubimage(1,i*16+3,&img_tilemap,21,21,8,8,DIMAGE_NONE);} //if select
            dsubimage(13,i*16+3,&img_tilemap,craftdata[i][0]*10,0,10,10,DIMAGE_NONE); //block to craft
            dprint(25, i*16+4, C_BLACK, "%d",craftdata[i][1]);
            dsubimage(75,i*16+3,&img_tilemap,craftdata[i][2]*10,0,10,10,DIMAGE_NONE);
            dprint(88, i*16+4, C_BLACK, "%d",craftdata[i][3]);
            dsubimage(95,i*16+3,&img_tilemap,craftdata[i][4]*10,0,10,10,DIMAGE_NONE);
            dprint(108, i*16+4, C_BLACK, "%d",craftdata[i][5]);
        }
        key = getkey_opt(opt, &timeout).key;
        if(key==KEY_EXIT){break;}
        if(key==KEY_OPTN){if(craft(s)){break;}}
        if(key==KEY_DOWN&&s<CRAFTS-1){s++;}
        if(key==KEY_UP&&s>0){s--;}
        dupdate();
    }
}

int main(void)
{
    int i = 10;
    while(i<MAP_X-10){
        game_map[i][5] = 1;
        game_map[i][4] = 2;
        i++;
        if(i>10 && i<MAP_X-10 && isMultipleof5(i) == 1){
            game_map[i][3] = 15;
            game_map[i][2] = 15;
            game_map[i][1] = 15;
            game_map[i][0] = 17;
            game_map[i-1][0] = 17;
            game_map[i+1][0] = 17;
            game_map[i-1][1] = 17;
            game_map[i+1][1] = 17;
            game_map[i-2][1] = 17;
            game_map[i+2][1] = 17;
            game_map[i+1][3] = 4;
        }
    }
    game_map[5][3] = 9;
    game_map[6][3] = 10;
    game_map[7][3] = 11;
    inv[3] = 15;
    inv[13] = 10;
    inv[17] = 5;
    while(1==1){
        if(keydown(KEY_OPTN)){vas=1;}else{vas=0;}
        sx = x-60;
        dclear(C_WHITE);
        //dtext(12, 1, C_BLACK, "item");
        PrintMap();
        dupdate();
        key = getkey_opt(opt, &timeout).key;
        if(keydown(KEY_VARS)==0&&can_move == 1 &&( isCollide(game_map[x/10][y/10+1]) == 0 || game_map[x/10][y/10+1]==3)){
            if(keydown(KEY_RIGHT)&&isCollide(game_map[x/10+1][y/10])){rwalk = 10;can_move=0;dir=1;vdir=1;}
            if(keydown(KEY_UP)&&game_map[x/10][y/10]==3){rwalk = 10;can_move=0;vdir=0;}
            if(keydown(KEY_LEFT)&&isCollide(game_map[x/10-1][y/10])){rwalk = 10;can_move=0;dir=0;vdir=3;}
            if(keydown(KEY_DOWN)&&game_map[x/10][y/10+1]==3){rwalk = 10;can_move=0;vdir=2;}
        }
        if(keydown(KEY_VARS)){
            if(keydown(KEY_RIGHT)){sele=1;}
            if(keydown(KEY_DOWN)){sele=2;}
            if(keydown(KEY_LEFT)){sele=3;}
            if(keydown(KEY_UP)){sele=0;}
        }
        if(can_move ==1 && keydown(KEY_OPTN)&& inv[sinv] > 0){

            if(sele==1&&game_map[x/10+1][y/10]==0){game_map[x/10+1][y/10]=sinv;inv[sinv]--;}
            if(sele==2&&game_map[x/10][y/10+1]==0){game_map[x/10][y/10+1]=sinv;inv[sinv]--;}
            if(sele==3&&game_map[x/10-1][y/10]==0){game_map[x/10-1][y/10]=sinv;inv[sinv]--;}
            if(sele==0&&game_map[x/10][y/10-1]==0){game_map[x/10][y/10-1]=sinv;inv[sinv]--;}
        }
        if(can_move ==1 && keydown(KEY_SQUARE)){
            if(sele==1){inv[game_map[x/10+1][y/10]]++;game_map[x/10+1][y/10]=0;}
            if(sele==2){inv[game_map[x/10][y/10+1]]++;game_map[x/10][y/10+1]=0;}
            if(sele==3){inv[game_map[x/10-1][y/10]]++;game_map[x/10-1][y/10]=0;}
            if(sele==0){inv[game_map[x/10][y/10-1]]++;game_map[x/10][y/10-1]=0;}
        }
        if(selecoll>0){selecoll--;}
        if(keydown(KEY_F6)&&selecoll==0){
                if(sinv==BLOCKS_LEN+1){sinv=1;}
                sinv++;
                selecoll = 20;
        }
        if(keydown(KEY_F5)&&selecoll==0){
                if(sinv==1){sinv=BLOCKS_LEN+1;}
                sinv--;
                selecoll = 20;
        }
        if(keydown(KEY_F1)){
                craftmenu();
        }
        if(can_move == 1 && game_map[x/10][y/10+1] == 0){
            can_move = 0;
            rwalk=10;
            vdir=2;
        }
        if(can_move==0&&rwalk>0){
            rwalk--;
            if(vdir==1){x++;}
            if(vdir==2){y++;}
            if(vdir==3){x--;}
            if(vdir==0){y--;}
            if(rwalk==0){can_move = 1;}
        }
    }
    getkey();
    return 1;
}

coucou je suis la...

pensés suicidaires: 90%

Avatar de _pedroBzh
Membre
Niveau 0 (27)
Niv. 0
1
2
def lunch_pomme_pot_fan_club():
    print("LOL")

coucou je suis la...

pensés suicidaires: 90%

Avatar de _pedroBzh
Membre
Niveau 0 (27)
Niv. 0

ca marche!


coucou je suis la...

pensés suicidaires: 90%

Ce topic est sans activité depuis 337 jours, êtes-vous sûr de vouloir y poster ?

Commenter le sujet