Skip to content

Commit

Permalink
int to long long
Browse files Browse the repository at this point in the history
  • Loading branch information
Creckeryop committed Oct 6, 2019
1 parent bdc3a7b commit 32bb3d9
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 22 deletions.
8 changes: 4 additions & 4 deletions src/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,22 @@ void load(int score)
record = score;
}

int save()
long long save()
{
return record;
}

int get_state()
long long get_state()
{
return state;
}

int get_score()
long long get_score()
{
return score;
}

int get_record()
long long get_record()
{
return record;
}
Expand Down
8 changes: 4 additions & 4 deletions src/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ extern bird BIRD;

bool get_day();
void load(int score);
int save();
int get_score();
int get_state();
int get_record();
long long save();
long long get_score();
long long get_state();
long long get_record();
float get_distance();
void update(float d = 1);
void tap(int t = 1);
4 changes: 3 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ int main(int argc, char *argv[])
sprites = vita2d_load_PNG_file("app0:assets.png");
vita2d_set_vblank_wait(1);
float d = 1;
int oldstate = -1, oldscore = 0;
int oldstate = -1;
long long oldscore = 0;
bool old_butt_flag = butt_flag;
SceUID fs = sceIoOpen("ux0:data/flappy_bird.save", SCE_O_RDONLY | SCE_O_CREAT,0777);
int size = sceIoLseek32(fs, 0, SCE_SEEK_END);
Expand Down Expand Up @@ -205,6 +206,7 @@ int main(int argc, char *argv[])
SceUID fs = sceIoOpen("ux0:data/flappy_bird.save", SCE_O_WRONLY | SCE_O_CREAT, 0777);
if (fs >= 0) {
char buff[64];
for (int i=0;i<64;i++) buff[i] = '\0';
itoa_m(get_record(), buff);
sceIoWrite(fs, buff, 64);
sceIoClose(fs);
Expand Down
23 changes: 12 additions & 11 deletions src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,23 @@ long long get_time()
return duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count();
}

int atoi_m(const char* c)
long long atoi_m(const char* c)
{
int tmp = 0;
long long tmp = 0;
while (*c || *c - 48 < 10 && *c - 48 >= 0) c++;
while (*c)
{
tmp *= 10;
if (*c-48<10 && *c-48>=0)
tmp+=(*(c++) - 48);
else
return 0;
}
{
tmp *= 10;
if (*c - 48 < 10 && *c - 48 >= 0)
tmp += (*(c++) - 48);
else
return tmp/10;
}
return tmp;
}
void itoa_m(int n, char* buff)
void itoa_m(long long n, char* buff)
{
int tmp = n, len = 1;
long long tmp = n, len = 1;
while (tmp / 10 != 0) tmp /= 10, len++;
buff += len - 1;
*(buff + 1) = '\0';
Expand Down
4 changes: 2 additions & 2 deletions src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
#pragma once

long long get_time();
int atoi_m(const char* c);
void itoa_m(int n, char* buff);
long long atoi_m(const char* c);
void itoa_m(long long n, char* buff);
float mod(float a, int x);

0 comments on commit 32bb3d9

Please sign in to comment.