Compare commits

..

No commits in common. "master" and "v-test1" have entirely different histories.

18 changed files with 421 additions and 594 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 118 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 149 B

After

Width:  |  Height:  |  Size: 134 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 476 B

After

Width:  |  Height:  |  Size: 355 B

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -87,4 +87,3 @@ LDFLAGS_CG += -Wl,-Map=build-cg/map
#
# FONT.hexa.png = charset:print grid.size:3x5 grid.padding:1
IMG.tilemap.png :=
IMG.craft.png :=

Binary file not shown.

Before

Width:  |  Height:  |  Size: 399 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 429 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 437 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 406 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 209 B

View File

@ -1,19 +1,13 @@
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;
#define MAP_X 50
int sx = 0;
int x = 100;
int x = 30;
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 game_map[MAP_X+1][7];
int opt = GETKEY_DEFAULT | GETKEY_REP_ARROWS | GETKEY_MENU;
int optd = GETKEY_DEFAULT | GETKEY_MENU;
int timeout = 1;
@ -22,24 +16,6 @@ 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;
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)
{
@ -51,89 +27,29 @@ int isMultipleof5 (int n)
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();
}
if(dir==0){dsubimage(x-sx, y+4 ,&img_tilemap,5*10,0,10, 10, DIMAGE_NONE);}
if(dir==1){dsubimage(x-sx, y+4 ,&img_tilemap,4*10,0,10, 10, DIMAGE_NONE);}
}
int main(void)
{
int i = 10;
while(i<MAP_X-10){
int i = 0;
while(i<MAP_X){
game_map[i][5] = 1;
game_map[i][4] = 2;
i++;
if(i>10 && i<MAP_X-10 && isMultipleof5(i) == 1){
if(i>5 && i<MAP_X-5 && isMultipleof5(i) == 1){
game_map[i][3] = 15;
game_map[i][2] = 15;
game_map[i][1] = 15;
@ -144,61 +60,21 @@ int main(void)
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");
dtext(1, 1, C_BLACK, "Sample fxSDK add-in.");
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 = 30;
}
if(keydown(KEY_F5)&&selecoll==0){
if(sinv==1){sinv=BLOCKS_LEN+1;}
sinv--;
selecoll = 30;
}
if(keydown(KEY_F1)){
craftmenu();
if(can_move == 1 && game_map[x/10][y/10+1] != 0){
if(keydown(KEY_RIGHT)){rwalk = 10;can_move=0;dir=1;vdir=1;}
if(keydown(KEY_LEFT)){rwalk = 10;can_move=0;dir=0;vdir=3;}
}
if(can_move == 1 && game_map[x/10][y/10+1] == 0){
can_move = 0;
@ -210,7 +86,6 @@ int main(void)
if(vdir==1){x++;}
if(vdir==2){y++;}
if(vdir==3){x--;}
if(vdir==0){y--;}
if(rwalk==0){can_move = 1;}
}
}