int main(int argc, char * argv[]) { oflux::doors::ClientDoor<S_out> door("/tmp/doorserver/S"); S_out s; int sz = argc ? atoi(argv[1]) : 1; for(int i=0; i < sz; ++i) { s.a = i; door.send(&s); } return 0; }
void DoorHandler::door() { std::cout << "You come across a door" << std::endl; std::cout << "Do you open the door? "; getline(std::cin, theAnswer); if (theAnswer == "Yes" || theAnswer == "yes") room.room(); else if (theAnswer == "No" || theAnswer == "no") misc.pit(); else { std::cout << "Something went wrong" << std::endl; door(); } }
IC void CCar::fill_doors_map(LPCSTR S,xr_map<u16,SDoor>& doors) { IKinematics* pKinematics =smart_cast<IKinematics*>(Visual()); string64 S1; int count = _GetItemCount(S); for (int i=0 ;i<count; ++i) { _GetItem (S,i,S1); u16 bone_id = pKinematics->LL_BoneID(S1); SDoor door(this); door.bone_id= bone_id; doors.insert (mk_pair(bone_id,door)); BONE_P_PAIR_IT J = bone_map.find(bone_id); if (J == bone_map.end()) { bone_map.insert(mk_pair(bone_id,physicsBone())); } } }
int main() { hOut = GetStdHandle(STD_OUTPUT_HANDLE); //标准输出句柄获得 SetConsoleCursorInfo(hOut, &cur_info); //隐藏光标 while(1) { system("cls");/*清屏*/ Snake* head = (Snake*)malloc(sizeof(Snake)); initialization(head); background(); while(1) { Sleep(500); refresh(); getkeys(); run(head); eat(head); if(door(head)) break; food(head); } release_list(head); SetConsoleCursorPosition(hOut, pos); SetConsoleTextAttribute(hOut, 0x07); system("cls");/*清屏*/ printf("得分:%d\n空格重新开始\n",scoring); while(1) { int w = getch(); if(w == ' ') { break; } else { continue; } } } return 0; }
void BedroomPlanBuilder::buildDoors() { Door door(1, 0, 2, 0); plan_->addDoor(door); }
void BathroomPlanBuilder::buildDoors() { Door door(0, 0, 0, 1); plan_->addDoor(door); }
void room::draw() { glColor3f(1, 1, 1); int doors_on = 1; float tileSize[3] = { 0.5, 0.5, 0.5 }; //Translate to the origin glTranslatef(origin[0], origin[1], origin[2]); int i, j; //Floor glPushMatrix(); for (i=0;i<dimensions[1];i++) { for (j=0;j<dimensions[0];j++) { //if (PtextMem.bottom_door[i][j] == 1 && doors_on == 1) { if (floorPads1.floorPadsPlaces[i][j] != 0 && doors_on == 1) { glBindTexture(GL_TEXTURE_2D, door1.floorPad); glBegin(GL_QUADS); glTexCoord2f(0.0f, 0.0f);glVertex3f(-tileSize[0], -tileSize[1], -tileSize[2]); glTexCoord2f(0.0f, 1.0f);glVertex3f(-tileSize[0], -tileSize[1], tileSize[2]); glTexCoord2f(1.0f, 1.0f);glVertex3f(tileSize[0], -tileSize[1], tileSize[2]); glTexCoord2f(1.0f, 0.0f);glVertex3f(tileSize[0], -tileSize[1], -tileSize[2]); glEnd(); } else { glBindTexture(GL_TEXTURE_2D, PtextMem.bottom_tex[i][j]); glBegin(GL_QUADS); glTexCoord2f(0.0f, 0.0f);glVertex3f(-tileSize[0], -tileSize[1], -tileSize[2]); glTexCoord2f(0.0f, 1.0f);glVertex3f(-tileSize[0], -tileSize[1], tileSize[2]); glTexCoord2f(1.0f, 1.0f);glVertex3f(tileSize[0], -tileSize[1], tileSize[2]); glTexCoord2f(1.0f, 0.0f);glVertex3f(tileSize[0], -tileSize[1], -tileSize[2]); glEnd(); } glTranslatef(1, 0, 0); } glTranslatef(-dimensions[0], 0, 1); } glPopMatrix(); //Move up to where the ceiling should be glTranslatef(0, dimensions[2], 0); //Ceiling for (i=0;i<dimensions[1];i++) { for (j=0;j<dimensions[0];j++) { if (PtextMem.top_door[i][j] != 0 && doors_on == 1) { glPushMatrix(); glRotatef(90, 1, 0, 0); if ( PtextMem.top_door[i][j] == 1) door(0, door1); glPopMatrix(); } else { glBindTexture(GL_TEXTURE_2D, PtextMem.top_tex[i][j]); glBegin(GL_QUADS); glTexCoord2f(1.0f, 0.0f);glVertex3f(tileSize[0], -tileSize[1], -tileSize[2]); glTexCoord2f(0.0f, 0.0f);glVertex3f(-tileSize[0], -tileSize[1], -tileSize[2]); glTexCoord2f(0.0f, 1.0f);glVertex3f(-tileSize[0], -tileSize[1], tileSize[2]); glTexCoord2f(1.0f, 1.0f);glVertex3f(tileSize[0], -tileSize[1], tileSize[2]); glEnd(); } glTranslatef(1, 0, 0); } glTranslatef(-dimensions[0], 0, 1); } //Move back down to floor level glTranslatef(0, -dimensions[2], -dimensions[1]); //Wall Left for (i=0;i<dimensions[2];i++) { for (j=0;j<dimensions[1];j++) { if (PtextMem.left_door[i][j] != 0 && doors_on == 1) { glPushMatrix(); glRotatef(90, 0, 1, 0); glTranslatef(0, 0, -1); if ( PtextMem.left_door[i][j] == 1) door(0, door1); glPopMatrix(); } else { glBindTexture(GL_TEXTURE_2D, PtextMem.left_tex[i][j]); glBegin(GL_QUADS); glTexCoord2f(0.0f, 0.0f);glVertex3f(-tileSize[0], tileSize[1], tileSize[2]); glTexCoord2f(0.0f, 1.0f);glVertex3f(-tileSize[0], tileSize[1], -tileSize[2]); glTexCoord2f(1.0f, 1.0f);glVertex3f(-tileSize[0], -tileSize[1], -tileSize[2]); glTexCoord2f(1.0f, 0.0f);glVertex3f(-tileSize[0], -tileSize[1], tileSize[2]); glEnd(); } glTranslatef(0, 0, 1); } glTranslatef(0, 1, -dimensions[1]); } //Move across the floor glTranslatef(dimensions[0]-1, -dimensions[2], 0); //Wall RIGHT for (i=0;i<dimensions[2];i++) { for (j=0;j<dimensions[1];j++) { if (PtextMem.right_door[i][j] != 0 && doors_on == 1) { glPushMatrix(); glRotatef(270, 0, 1, 0); glTranslatef(0, 0, -1); if ( PtextMem.right_door[i][j] == 1) door(0, door1); glPopMatrix(); } else { glBindTexture(GL_TEXTURE_2D, PtextMem.right_tex[i][j]); glBegin(GL_QUADS); glTexCoord2f(0.0f, 0.0f);glVertex3f(tileSize[0], tileSize[1], tileSize[2]); glTexCoord2f(0.0f, 1.0f);glVertex3f(tileSize[0], tileSize[1], -tileSize[2]); glTexCoord2f(1.0f, 1.0f);glVertex3f(tileSize[0], -tileSize[1], -tileSize[2]); glTexCoord2f(1.0f, 0.0f);glVertex3f(tileSize[0], -tileSize[1], tileSize[2]); glEnd(); } glTranslatef(0, 0, 1); } glTranslatef(0, 1, -dimensions[1]); } //Move to the back wall glTranslatef(-dimensions[0]+1, -dimensions[2], dimensions[1]); //Back Wall for (i=0;i<dimensions[2];i++) { for (j=0;j<dimensions[0];j++) { if (PtextMem.back_door[i][j] != 0 && doors_on == 1) { glPushMatrix(); glRotatef(-180, 0, 1, 0); if ( PtextMem.back_door[i][j] == 1) door(0, door1); glPopMatrix(); } else { glBindTexture(GL_TEXTURE_2D, PtextMem.back_tex[i][j]); glBegin(GL_QUADS); //Left glTexCoord2f(0.0f, 1.0f);glVertex3f(-tileSize[0], tileSize[1], -tileSize[2]); glTexCoord2f(1.0f, 1.0f);glVertex3f(tileSize[0], tileSize[1], -tileSize[2]); glTexCoord2f(1.0f, 0.0f);glVertex3f(tileSize[0], -tileSize[1], -tileSize[2]); glTexCoord2f(0.0f, 0.0f);glVertex3f(-tileSize[0], -tileSize[1], -tileSize[2]); glEnd(); } glTranslatef(1, 0, 0); } glTranslatef(-dimensions[0], 1, 0); } //TO THE FRONT TO THE FRONT glTranslatef(0, -dimensions[2], -dimensions[1]-1); //Front Wall for (i=0;i<dimensions[2];i++) { for (j=0;j<dimensions[0];j++) { if (PtextMem.front_door[i][j] != 0 && doors_on == 1) { if ( PtextMem.front_door[i][j] == 1) door(0, door1); } else { glBindTexture(GL_TEXTURE_2D, PtextMem.front_tex[i][j]); glBegin(GL_QUADS); //Left glTexCoord2f(0.0f, 1.0f);glVertex3f(-tileSize[0], tileSize[1], tileSize[2]); glTexCoord2f(1.0f, 1.0f);glVertex3f(tileSize[0], tileSize[1], tileSize[2]); glTexCoord2f(1.0f, 0.0f);glVertex3f(tileSize[0], -tileSize[1], tileSize[2]); glTexCoord2f(0.0f, 0.0f);glVertex3f(-tileSize[0], -tileSize[1], tileSize[2]); glEnd(); } glTranslatef(1, 0, 0); } glTranslatef(-dimensions[0], 1, 0); } }
// // LoadMap // void Raycaster::LoadMap(const char *filename) { int i, j; FILE *fp; char c, errMsg[MAX_STR_LENGTH]; mapChange = false; ClearMap(); doors.clear(); mapH = framework->CountRowsInFile(filename); mapW = framework->CountColsInFile(filename); fp = fopen(filename, "r"); if(!fp) { sprintf(errMsg, "Can't load file: %s!", filename); framework->Error(errMsg); } for(i=0; i<mapH; i++) { for(j=0; j<mapW; j++) { c = fgetc(fp); while(!IS_VALID_CHAR(c) && !feof(fp)) c = fgetc(fp); if(feof(fp) || !IS_VALID_CHAR(c)) break; if(c >= '0' && c <= '9') map[i][j] = c - '0'; else if(c >= 'A' && c <= 'Z') map[i][j] = c - 'A' + 10; else if(c >= 'a' && c <= 'z') { if(c == 'z') { posX = j + 0.5f; posY = i + 0.5f; map[i][j] = 0; } else map[i][j] = c - 'a' + 36; } if(map[i][j] == DOOR_INDEX) { Door door(j, i, this); doors.push_back(door); } else if(map[i][j] == LOCKED_DOOR_INDEX) { Door door(j, i, this, true); doors.push_back(door); } } } fclose(fp); }
void mainLevel(RenderWindow &window) { //>>>>>>>>>>>>>>>---Level---<<<<<<<<<<<<<<<<<<<<<<<<<<< Level lvl; lvl.LoadFromFile("map.tmx"); //>>>>>>>>>>>>>>>>---Load basic image for level1----<<<<<<<<<<<<<<<<< Texture texture; texture.loadFromFile("images/level1empty.jpg"); Sprite level(texture); Texture texture2; texture2.loadFromFile("images/levelShad.png"); Sprite level2(texture2); Texture texture3; texture3.loadFromFile("images/level12.png"); Sprite level3(texture3); //>>>>>>>>>>>>>>>>---Music---<<<<<<<<<<<<<<<<<<<<<<<<<< Music mainSong; Music skyrim, muse, bathMus; bathMus.openFromFile("music/bath.ogg"); Object mus = lvl.GetObject("muse"); muse.openFromFile("music/synd.ogg"); muse.setVolume(100); skyrim.openFromFile("music/skyrim.ogg"); skyrim.setVolume(100); mainSong.openFromFile("music/level1.ogg"); mainSong.play(); mainSong.setLoop(true); mainSong.setVolume(75); //>>>>>>>>>>>>>>>>---Create a cat---<<<<<<<<<<<<<<<<<<< Object player = lvl.GetObject("cat"); Object fish = lvl.GetObject("fish"); Object mo = lvl.GetObject("mouse"); Object ob = lvl.GetObject("catPlace"); Player cat("cat.png", lvl, 68, 429, 60, 120, player.rect.left, player.rect.top, ELSE); Clock clock; Clock gameTimeClock; int sinkCnt = 0; //>>>>>>>>>>>>>>>>---Sounds----<<<<<<<<<<<<<<<<<<< SoundBuffer buf1, buf2; buf1.loadFromFile("music/meow1.ogg"); buf2.loadFromFile("music/meow2.ogg"); Sound meow1, meow2; meow1.setBuffer(buf1); meow2.setBuffer(buf2); SoundBuffer buf, buf3; buf.loadFromFile("music/steklo.ogg"); buf3.loadFromFile("music/mouse.ogg"); Sound glass; Sound mouseS; glass.setBuffer(buf); glass.setVolume(100); mouseS.setBuffer(buf3); //Objects Furniture posters("tayles1.png", 160, 660, 210, 250, 280, 215, POSTERS); Furniture bed("tayles1.png", 420, 80, 280, 310, 250, 440, ELSE); Furniture toys("tayles1.png", 120, 470, 180, 150, 220, 545, TOYS); Furniture upShelf("tayles1.png", 700, 652.5, 120, 97.5, 350, 83, SHELF); Furniture cabinet("tayles1.png", 75, 40, 250, 350, 605, 305, CABINET); Furniture mop("tayles1.png", 515, 785, 165, 241, 587, 385, MOP); Furniture flower("tayles1.png",780, 65, 170, 330, 147, 285, ELSE); Furniture ball("tayles1.png", 905, 615, 40, 55, 357, 190, BALL); Furniture books("tayles1.png", 860, 735, 125, 80, 290, 187, BOOKS); Furniture brokenBall("tayles1.png",920, 540, 90, 42, 430, 430, ELSE); Furniture key("tayles1.png", 1, 1, 25, 25, 430, 425, KEY); Furniture cabinetEnd("cabinet.png", 20, 50, 270, 350, 590, 290, ELSE); Furniture girl("girlHair.png", 1,1, 96, 45, 1075, 350, ELSE); Furniture door("tayles2.png", 0, 560, 80, 340, 870, 350, ELSE); Furniture puddle("tayles1.png",789, 1000, 204, 75, 1057, 559, ELSE); Furniture brokenLight("tayles2.png", 10, 110, 50, 70, 795, 430, ELSE); Furniture light("tayles2.png", 20, 20, 35, 70, 220, 565, ELSE); Furniture bath("tayles2.png", 80, 50, 320, 380, 1010, 330, BATH); Furniture openBath("bathr.png", 264, 79, 339, 369, 1015, 315, ELSE); Furniture carpet("tayles2.png", 100, 500, 100, 140, 870, 530, ELSE); Furniture mirror("tayles2.png", 90, 700, 110, 290, 1200, 300, ELSE); Furniture sink("tayles2.png", 290, 440, 150, 240, 1190, 450, SINK); Furniture sinkWater("bathr.png", 22, 180, 197, 427, 1200, 540, ELSE); Furniture mou("mouse.png", 2, 21, 32, 25, mo.rect.left, mo.rect.top, ELSE); std::list<Furniture> fList; std::list<Furniture>::iterator it; fList.push_back(posters); fList.push_back(toys); fList.push_back(upShelf); fList.push_back(cabinet); fList.push_back(mop); fList.push_back(ball); fList.push_back(books); fList.push_back(key); fList.push_back(puddle); fList.push_back(brokenLight); fList.push_back(bath); fList.push_back(sink); for(it = fList.begin(); it != fList.end(); it++){ it->setSub((void *)&it, writeMess); } int cntMeow = 1, cntGame = 0, click = 0, clickBath = 1, clickSink = 1; bath.isPlayed = true; sink.isPlayed = true; while (window.isOpen()) { float time = clock.getElapsedTime().asMicroseconds(); float sinkTime = gameTimeClock.getElapsedTime().asSeconds(); if(clickSink < 2) gameTimeClock.restart(); clock.restart(); time = time/500; Vector2i pos = Mouse::getPosition(window); Event event; while (window.pollEvent(event)) { if (event.type == sf::Event::Closed) window.close(); if (event.type == Event::MouseButtonPressed) if (event.key.code == Mouse::Left){ if (fish.rect.contains(pos.x, pos.y) && key.isPlayed == true){ mainSong.stop(); finish(); window.close(); } if (cat.sprite.getGlobalBounds().contains(pos.x, pos.y)) { cntMeow++; if(cntMeow == 5) { meow2.play(); cntMeow = 0; } else meow1.play(); } toys.trueMove(pos); if(light.isPlayed == false) light.trueMove(pos); if(ball.isPlayed == true && books.isPlayed == true) key.trueMove(pos); if(puddle.isPlayed == true) mop.trueMove(pos); click = light.clickedThings(pos); clickBath = bath.clickedThings(pos); clickSink = sink.clickedThings(pos); if (upShelf.sprite.getGlobalBounds().contains(pos.x, pos.y)){ skyrim.play(); } if (mus.rect.contains(pos.x, pos.y)){ muse.play(); } if (girl.sprite.getGlobalBounds().contains(pos.x, pos.y) && cat.room == 2){ mainSong.pause(); gameOver(); mainSong.play(); } if(mou.isPlayed == false) { if (mou.sprite.getGlobalBounds().contains(pos.x, pos.y)) { mainSong.pause(); mouseS.play(); //gameRunning(); mou.isPlayed = true; mainSong.play(); } } if(books.isPlayed == false) { if (books.sprite.getGlobalBounds().contains(pos.x, pos.y)) { mainSong.pause(); MiniGame_Books(); books.isPlayed = true; mainSong.play(); } } } if (event.type == Event::MouseButtonReleased) if (event.key.code == Mouse::Left){ toys.isMove = false; key.isMove = false; if(light.isPlayed == false) light.isMove = false; mop.isMove = false; } } if(sinkTime > 5 && clickSink == 2) puddle.isPlayed = true; if(clickBath == 2 && cat.room == 2) bathMus.play(); if(click == -1){} else if(click == 1 || click == 2) cat.room = click; toys.intersect("toys",lvl); toys.move(pos); if(mop.isPlayed == false) { mop.intersect("mop", lvl); mop.move(pos); } if(light.isPlayed == false) { light.intersect("light", lvl); light.move(pos); } if(ball.isPlayed == true && books.isPlayed == true){ if(mop.isPlayed == true) key.intersect("key", lvl); if(key.isPlayed == false) key.move(pos); } if(ball.isPlayed == false && books.isPlayed == true){ if(cat.sprite.getGlobalBounds().intersects(ob.rect)) { if(cntMeow == 0) { ball.falling(event, window, pos, lvl, time); glass.play(); ball.isPlayed = true; ball.intersect("ball", lvl); } } } cat.Update(time); window.clear(Color::Black); lvl.Draw(window); if(cat.room == 0) window.draw(level); if(cat.room == 1) window.draw(level2); if(cat.room == 2) window.draw(level3); window.draw(posters.sprite); window.draw(bed.sprite); if(key.isPlayed == true) window.draw(cabinetEnd.sprite); else window.draw(cabinet.sprite); window.draw(upShelf.sprite); window.draw(flower.sprite); if(ball.isPlayed == false) window.draw(ball.sprite); else { window.draw(brokenBall.sprite); window.draw(key.sprite); } window.draw(books.sprite); if(mou.isPlayed == false){ window.draw(mou.sprite); } else window.draw(light.sprite); window.draw(toys.sprite); if(cat.room == 2){ if(clickBath == 2){ window.draw(girl.sprite); window.draw(openBath.sprite); } else window.draw(bath.sprite); window.draw(mirror.sprite); if(clickSink == 2) window.draw(sinkWater.sprite); else window.draw(sink.sprite); if(puddle.isPlayed == true && mop.isPlayed == false) window.draw(puddle.sprite); } if(cat.room == 1 || cat.room == 2){ if(light.isPlayed == false) window.draw(brokenLight.sprite); window.draw(carpet.sprite); window.draw(door.sprite); } if(mop.isPlayed == false) window.draw(mop.sprite); window.draw(cat.sprite); for(it = fList.begin(); it != fList.end(); it++) { if(it->sprite.getGlobalBounds().contains(pos.x, pos.y)) { if(it->f.cb_fn != NULL) { cb_fn fn; fn = (cb_fn)it->f.cb_fn; fn(&window, it->type, &pos); } } } window.display(); } }
void main() { UBYTE i, j; disable_interrupts(); DISPLAY_OFF; LCDC_REG = 0x67; /* * LCD = Off * WindowBank = 0x9C00 * Window = On * BG Chr = 0x8800 * BG Bank = 0x9800 * OBJ = 8x16 * OBJ = On * BG = On */ doorstate = CLOSED; /* Set palettes */ BGP_REG = OBP0_REG = OBP1_REG = 0xE4U; /* Initialize the background */ set_bkg_data(0xFC, 0x04, std_data); set_bkg_data(0x00, 0x2D, bkg_data); /* * Draw the background * * Width = 0x100 = 0x20 * 8 * Height = 0x100 = 0x20 * 8 */ for(i = 0; i < 32; i+=8) for(j = 0; j < 32; j+=8) set_bkg_tiles(i, j, 8, 8, bkg_tiles); bposx.w = 0; SCX_REG = 0; bposy.w = 0; SCY_REG = 0; bspx.w = 0xFF00; bspy.w = 0x0080; /* Initialize the window */ set_win_data(0x80, 0x21, frame_data); /* * Draw the frame in the window * * Width = 0x80 = 0x10 * 8 * Height = 0x50 = 0x0A * 8 */ set_win_tiles(0, 0, 16, 10, frame_tiles); /* * Draw the door in the window * * Width = 0x60 = 0x20 * 12 * Height = 0x30 = 0x20 * 6 */ set_win_tiles(2, 2, 12, 6, door1_tiles); wposx.b.h = MAXWNDPOSX; wposx.b.l = 0; WX_REG = MAXWNDPOSX; wposy.b.h = MAXWNDPOSY; wposy.b.l = 0; WY_REG = MAXWNDPOSY; wspx.w = 0xFF80; wspy.w = 0xFFC0; /* Initialize the sprite */ set_sprite_data(0x00, 0x1C, earth_data); set_sprite_prop(0, 0x00); set_sprite_prop(1, 0x00); sframe = 0; sposx.w = 0x1000; sposy.w = 0x1000; sspx.w = 0x0040; sspy.w = 0x0040; tile_sprite(); place_sprite(); DISPLAY_ON; enable_interrupts(); while(1) { /* Skip four VBLs (slow down animation) */ for(i = 0; i < 4; i++) wait_vbl_done(); time++; fade(); door(); scroll(); animate_sprite(); i = joypad(); if(i & J_B) { if(i & J_UP) bspy.w -= 0x0010; if(i & J_DOWN) bspy.w += 0x0010; if(i & J_LEFT) bspx.w -= 0x0010; if(i & J_RIGHT) bspx.w += 0x0010; } else if(i & J_A) { if(i & J_UP) wspy.w -= 0x0010; if(i & J_DOWN) wspy.w += 0x0010; if(i & J_LEFT) wspx.w -= 0x0010; if(i & J_RIGHT) wspx.w += 0x0010; } else { if(i & J_SELECT) color = STARTFADE; if(i & J_START) if(doorstate == CLOSED) { doorstate = OPENING; doorpos = 0; } else if(doorstate == OPENED) { doorstate = CLOSING; doorpos = NBDFRAMES; } if(i & J_UP) sspy.w -= 0x0010; if(i & J_DOWN) sspy.w += 0x0010; if(i & J_LEFT) sspx.w -= 0x0010; if(i & J_RIGHT) sspx.w += 0x0010; } } }
void mainLevel(RenderWindow &window) { //>>>>>>>>>>>>>>>---Level---<<<<<<<<<<<<<<<<<<<<<<<<<<< Level lvl; lvl.LoadFromFile("map.tmx"); //>>>>>>>>>>>>>>>>---Load basic image for level1----<<<<<<<<<<<<<<<<< Texture texture; texture.loadFromFile("images/level1empty.jpg"); Sprite level(texture); Texture texture2; texture2.loadFromFile("images/levelShad.png"); Sprite level2(texture2); Texture texture3; texture3.loadFromFile("images/level12.png"); Sprite level3(texture3); //>>>>>>>>>>>>>>>>---Music---<<<<<<<<<<<<<<<<<<<<<<<<<< Music mainSong; mainSong.openFromFile("music/level1.ogg"); mainSong.play(); mainSong.setLoop(true); mainSong.setVolume(75); //>>>>>>>>>>>>>>>>---Create a cat---<<<<<<<<<<<<<<<<<<< Object player = lvl.GetObject("cat"); Player cat("cat.png", lvl, player.rect.left, player.rect.top, 60, 120, 55, 25); Clock clock; //>>>>>>>>>>>>>>>>---Sounds----<<<<<<<<<<<<<<<<<<< SoundBuffer buf1, buf2; buf1.loadFromFile("music/meow1.ogg"); buf2.loadFromFile("music/meow2.ogg"); Sound meow1, meow2; meow1.setBuffer(buf1); meow2.setBuffer(buf2); SoundBuffer buf; buf.loadFromFile("music/steklo.ogg"); Sound glass; glass.setBuffer(buf); glass.setVolume(100); //Objects Furniture posters("tayles1.png", 160, 660, 210, 250, 280, 215); Furniture bed("tayles1.png", 420, 80, 280, 310, 250, 440); Furniture toys("tayles1.png", 120, 470, 180, 150, 220, 545); Furniture upShelf("tayles1.png", 700, 652.5, 120, 97.5, 350, 83); Furniture cabinet("tayles1.png", 75, 40, 250, 350, 605, 305); Furniture mop("tayles1.png", 515, 785, 165, 241, 587, 385); Furniture flower("tayles1.png",780, 65, 170, 330, 147, 285); Furniture ball("tayles1.png", 905, 615, 40, 55, 357, 190); Furniture books("tayles1.png", 860, 735, 125, 80, 290, 187); Furniture brokenBall("tayles1.png",920, 540, 90, 42, 430, 430); Furniture door("tayles2.png", 0, 560, 80, 340, 870, 350); Furniture brokenLight("tayles2.png", 10, 110, 50, 70, 795, 430); Furniture light("tayles2.png", 20, 20, 35, 70, 220, 565); Furniture bath("tayles2.png", 80, 50, 320, 380, 1010, 330); Furniture carpet("tayles2.png", 100, 500, 100, 140, 870, 530); Furniture mirror("tayles2.png", 90, 700, 110, 290, 1200, 300); Furniture sink("tayles2.png", 290, 440, 150, 240, 1190, 450); int cntMeow = 0; Object ob = lvl.GetObject("catPlace"); while (window.isOpen()) { float time = clock.getElapsedTime().asMicroseconds(); clock.restart(); time = time/500; Vector2i pos = Mouse::getPosition(window); Event event; while (window.pollEvent(event)) { if (event.type == sf::Event::Closed) window.close(); if (event.type == Event::MouseButtonPressed){ if (event.key.code == Mouse::Left) { int cntMeow = meow(meow1, meow2, cat, pos); //>>>>>>BALL<<<<<<<<<<<<<< if(cat.sprite.getGlobalBounds().intersects(ob.rect)) { if(cntMeow == -1) { ball.falling(event, window, pos, lvl, time); glass.play(); ball.moving(event, window, pos, "ball", lvl); } } cat.clickedThings(window, light); //BOOKS>>>>----<<<<<< if(books.isPlayed == false) { if (books.sprite.getGlobalBounds().contains(pos.x, pos.y)) { mainSong.pause(); MiniGame_Books(); books.isPlayed = true; mainSong.play(); } } } } toys.moving(event, window, pos, "toys", lvl); if(light.isPlayed == false) light.moving(event, window, pos, "light", lvl); } cat.Update(time); window.clear(Color::Black); lvl.Draw(window); if(cat.room == 0) window.draw(level); if(cat.room == 1) window.draw(level2); if(cat.room == 2) window.draw(level3); window.draw(posters.sprite); window.draw(bed.sprite); window.draw(light.sprite); window.draw(toys.sprite); window.draw(upShelf.sprite); window.draw(cabinet.sprite); window.draw(mop.sprite); window.draw(flower.sprite); if(ball.isPlayed == false) window.draw(ball.sprite); else window.draw(brokenBall.sprite); window.draw(books.sprite); if(cat.room == 2){ window.draw(bath.sprite); window.draw(mirror.sprite); window.draw(sink.sprite); } if(cat.room == 1 || cat.room == 2){ if(light.isPlayed == false) window.draw(brokenLight.sprite); window.draw(carpet.sprite); window.draw(door.sprite); } window.draw(cat.sprite); window.display(); } }
int main() { AppEnv env(3000, 2048, false, true); //ゲームの素材(主人公) Texture anb_top("res/anb1.png");//正面 Texture anb_side("res/anb2.png");//横 Texture anb_back("res/anb3.png");//後ろ //素材その他 Texture title("res/title_top.png"); Texture title2("res/title2.png"); Texture owari("res/owari.png"); Texture door("res/door.png"); Texture door2("res/door2.png"); Texture titledoorhan("res/titledoorhan.png"); Texture akari("res/akari.png"); Texture hp("res/heart.png"); Texture open("res/open.png"); Texture closed("res/closed.png"); Texture end("res/endcard.png"); //音源 Media nock("res/nock.wav"); Media keyclose("res/keyclose.wav"); //キャラの移動x,y int x = -1500; int y = -1024; // int stage_count = 0; int life = 3; int stage_clear=0; int block_x = 200; int block_y = 200; int akari_count = 0; int atari_count = 0; //stage_clear = 1; //**************************************おおもと************************************** while (true){ env.begin(); //::::::::::::::::::::::タイトル画面:::::::::::::::::::::::: while (env.isOpen()) { env.begin(); drawTextureBox(-1500, -1024, 3000, 2048, 0, 0, 4096, 2048, title); drawTextureBox(-1050, -600, 200, 200, 0, 0, 512, 512, open); drawTextureBox(100, -600, 200, 200, 0, 0, 512, 512, closed); if (!(-330 < x || -830 > x + 300 || -174 < y || -1024 > y + 600)){ drawTextureBox(-828, -1010, 510, 840, 0, 0, 512, 512, titledoorhan); if (env.isPressKey(GLFW_KEY_SPACE)){ x = -40; y = -1024; nock.play(); break; } } //右ドア if (stage_clear == 1){ drawTextureBox(100, -600, 200, 200, 0, 0, 512, 512, open); if (!(835 < x || 325 > x + 300 || -184 < y || -1024 > y + 600)){ drawTextureBox(320, -1010, 510, 840, 0, 0, 512, 512, titledoorhan); if (env.isPressKey(GLFW_KEY_SPACE)){ x = -40; y = -1024; nock.play(); stage_count = 11; break; } } } else { if (env.isPushKey(GLFW_KEY_SPACE)){ if (!(835 < x || 325 > x + 300 || -184 < y || -1024 > y + 600)){ keyclose.play(); } } } if (env.isPressKey(GLFW_KEY_LEFT)){ x -= 5; drawTextureBox(x, y, 300, 600, 0, 0, -256, 512, anb_side, Color(1, 1, 1, 1)); if (x <-1500){ x = -1500; } } else if (env.isPressKey(GLFW_KEY_RIGHT)){ x += 5; drawTextureBox(x, y, 300, 600, 0, 0, 256, 512, anb_side, Color(1, 1, 1, 1)); if (x > 1200){ x = 1200; } } else { drawTextureBox(x, y, 300, 600, 0, 0, 256, 512, anb_top, Color(1, 1, 1, 1)); } //if(!( □+x<x || □x >x+300 || □+y <y || □y > y+600)) env.end(); } //:::::::::::::::::::::::ゲーム本編::::::::::::::::::::::::::: while (env.isOpen()) { Vec2f pos = env.mousePosition(); env.begin(); //--------------------チュートリアル--------------------- //背景 if (stage_count == 0){ drawFillBox(-1024, -1024, 2048, 2048, Color(1, 1, 1, 1)); //ドア drawTextureBox(-40, 824, 100, 200, 0, 0, 256, 512, door); if (!(60 < x || -40 > x + 80 || 1024 < y || 824 > y + 160)){ drawTextureBox(-40, 824, 100, 200, 0, 0, 256, 512, door2); if (env.isPressKey(GLFW_KEY_SPACE)){ stage_count++; x = -40; y = -1024; nock.play(); } } //drawTextureBox(-40, 30, 80, 160, 0, 0, 256, 512, door2); // キャラの移動&移動制限 if (env.isPressKey(GLFW_KEY_UP)){ y += 5; drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_back, Color(1, 1, 1, 1)); if (y > 864.0f){ y = 864.0f; } } else if (env.isPressKey(GLFW_KEY_LEFT)){ x -= 5; drawTextureBox(x, y, 80, 160, 0, 0, -256, 512, anb_side, Color(1, 1, 1, 1)); } else if (env.isPressKey(GLFW_KEY_DOWN)){ y -= 5; drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_top, Color(1, 1, 1, 1)); if(y< -1024.0f){ y = -1024.0f; } } else if (env.isPressKey(GLFW_KEY_RIGHT)){ x += 5; drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_side, Color(1, 1, 1, 1)); } else { drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_top, Color(1, 1, 1, 1)); } //マップ&当たり判定 //if(!( □+x<x || □x >x+80 || □+y <y || □y > y+160)) drawFillBox(500, -1024, 600, 2048, Color(0, 0, 0, 1)); if (!(1100 < x || 500 > x + 80 || 1024 < y || -1024 > y + 100)){ x = -40; y = -1024; } drawFillBox(-1100, -1024, 600, 2048, Color(0,0,0, 1));//0.02 if (!(-500 < x || -1100 > x + 80 || 1024 < y || -1024 > y + 160)){ x = -40; y = -1024; } drawFillBox(-300, 0, 500, 200, Color(0,0,0,1)); if (!(200 < x || -300 > x + 80 || 200 < y || 0 > y + 160)){ x = -40; y = -1024; } } //----------------------ステージ1-------------------------------------------------------------- if (stage_count == 1){ drawFillBox(-1024, -1024, 2048, 2048, Color(40 / 255, 34 / 255, 42 / 255, 1)); drawTextureBox(-40, 824, 100, 200, 0, 0, 256, 512, door); if (!(60 < x || -40 > x + 80 || 1024 < y || 824 > y + 160)){ drawTextureBox(-40, 824, 100, 200, 0, 0, 256, 512, door2); if (env.isPressKey(GLFW_KEY_SPACE)){ stage_count++; x = -40; y = -1024; nock.play(); } } // キャラの移動&移動制限 if (env.isPressKey(GLFW_KEY_UP)){ y += 5; drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_back, Color(1, 1, 1, 0.4)); if (y > 864.0f){ y = 864.0f; } } else if (env.isPressKey(GLFW_KEY_LEFT)){ x -= 5; drawTextureBox(x, y, 80, 160, 0, 0, -256, 512, anb_side, Color(1, 1, 1, 0.4)); if (x < -1024.0f){ x = -1024.0f; } } else if (env.isPressKey(GLFW_KEY_DOWN)){ y -= 5; drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_top, Color(1, 1, 1, 0.4)); if (y < -1024.0f){ y = -1024.0f; } } else if (env.isPressKey(GLFW_KEY_RIGHT)){ x += 5; drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_side, Color(1, 1, 1, 0.4)); if (x > 1024.0f){ x = 1024.0f; } } else { drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_top, Color(1, 1, 1, 0.4)); } //マップ&当たり判定 //if(!( <x || >x+80 || <y ||> y+160)) //if(!(ax2 < bx1 || ax1 > bx2 || ay1< by2 || ay2 >by1)) drawFillBox(500, -1024, 100, 2048, Color(1, 1, 1, 0.02)); if (!(600 < x || 500 > x + 80 || 1024 < y || -1024 > y + 100)){ x = -40; y = -1024; } drawFillBox(-500, -1024, 100, 2048, Color(1, 1, 1, 0.02));//0.02 if (!(-400 < x || -500 > x + 80 || 1024 < y || -1024 > y + 160)){ x = -40; y = -1024; } drawFillBox(-400, 0, 500, 200, Color(1, 1, 1, 0.02)); if (!(100 < x || -400 > x + 80 || 200 < y || 0 > y + 160)){ x = -40; y = -1024; } drawFillBox(0, -500, 500, 200, Color(1, 1, 1, 0.02)); if (!(500 < x || 0 > x + 80 || -300 < y || -500 > y + 160)){ x = -40; y = -1024; } drawFillBox(-150, 500, 400, 200, Color(1, 1, 1, 0.02)); if (!(250 < x || -150 > x + 80 || 700 < y || 500 > y + 160)){ x = -40; y = -1024; } //キャラの明かり drawFillCircle(x + 40, y + 80, 130, 130, 100, Color(1, 1, 1, 0.13)); } //--------------------2ステージ------------------------------------------------------------ if (stage_count == 2){ drawFillBox(-1024, -1024, 2048, 2048, Color(1, 1, 1, 1)); drawTextureBox(-40, 824, 100, 200, 0, 0, 256, 512, door); if (!(60 < x || -40 > x + 80 || 1024 < y || 824 > y + 160)){ drawTextureBox(-40, 824, 100, 200, 0, 0, 256, 512, door2); if (env.isPressKey(GLFW_KEY_SPACE)){ stage_count++; x = -40; y = -1024; nock.play(); } } // キャラの移動&移動制限 if (env.isPressKey(GLFW_KEY_UP)){ y += 5; drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_back, Color(1, 1, 1, 1)); if (y > 864.0f){ y = 864.0f; } } else if (env.isPressKey(GLFW_KEY_LEFT)){ x -= 5; drawTextureBox(x, y, 80, 160, 0, 0, -256, 512, anb_side, Color(1, 1, 1, 1)); if (x < -1024.0f){ x = -1024.0f; } } else if (env.isPressKey(GLFW_KEY_DOWN)){ y -= 5; drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_top, Color(1, 1, 1, 1)); if (y < -1024.0f){ y = -1024.0f; } } else if (env.isPressKey(GLFW_KEY_RIGHT)){ x += 5; drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_side, Color(1, 1, 1, 1)); if (x > 1024.0f){ x = 1024.0f; } } else { drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_top, Color(1, 1, 1, 1)); } //明かり的な? drawFillCircle(x + 40, y + 80, 130, 130, 100, Color(0, 0, 0, 0.1)); //マップ&当たり判定 //if(!( <x || >x+80 || <y ||> y+160)) //if(!(ax2 < bx1 || ax1 > bx2 || ay1< by2 || ay2 >by1)) drawFillBox(500, -1024, 100, 2048, Color(1, 1, 1)); if (!(600 < x || 500 > x + 80 || 1024 < y || -1024 > y + 100)){ x = -40; y = -1024; } drawFillBox(-500, -1024, 100, 2048, Color(1, 1, 1));//0.02 if (!(-400 < x || -500 > x + 80 || 1024 < y || -1024 > y + 160)){ x = -40; y = -1024; } drawFillBox(-400, 0, 500, 200, Color(1, 1, 1)); if (!(100 < x || -400 > x + 80 || 200 < y || 0 > y + 160)){ x = -40; y = -1024; } drawFillBox(0, -500, 500, 200, Color(1, 1, 1)); if (!(500 < x || 0 > x + 80 || -300 < y || -500 > y + 160)){ x = -40; y = -1024; } drawFillBox(-150, 500, 400, 200, Color(1, 1, 1)); if (!(250 < x || -150 > x + 80 || 700 < y || 500 > y + 160)){ x = -40; y = -1024; } } //---------------------ステージ3------------------------------------------------------------------------- if (stage_count == 3){ drawFillBox(-1024, -1024, 2048, 2048, Color(1, 1, 1, 1)); drawTextureBox(-40, 824, 100, 200, 0, 0, 256, 512, door); if (!(60 < x || -40 > x + 80 || 1024 < y || 824 > y + 160)){ drawTextureBox(-40, 824, 100, 200, 0, 0, 256, 512, door2); if (env.isPressKey(GLFW_KEY_SPACE)){ x = -1500; y = -1024; stage_count = 0; stage_clear = 1; nock.play(); break; } } if (env.isPressKey(GLFW_KEY_UP)){ y += 5; drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_back, Color(1, 1, 1, 1)); if (y > 864.0f){ y = 864.0f; } } else if (env.isPressKey(GLFW_KEY_LEFT)){ x -= 5; drawTextureBox(x, y, 80, 160, 0, 0, -256, 512, anb_side, Color(1, 1, 1, 1)); if (x < -1024.0f){ x = -40; y = -1024; } } else if (env.isPressKey(GLFW_KEY_DOWN)){ y -= 5; drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_top, Color(1, 1, 1, 1)); if (y < -1024.0f){ y = -1024.0f; } } else if (env.isPressKey(GLFW_KEY_RIGHT)){ x += 5; drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_side, Color(1, 1, 1, 1)); if (x > 944.0f){ x = -40; y = -1024; } } else { drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_top, Color(1, 1, 1, 1)); } drawFillBox(block_x, block_y, 200, 200, Color::black); if (!(block_x + 200 < x || block_x > x + 80 || block_y + 200 < y || block_y > y + 160)){ x = -40; y = -1024; } if (!(200 < x || 0 > x + 80 || 400 < y || 200 > y + 160)){ block_x = 0; } } //--------------------------------------------すてーじ1-------------------------------------------- if (stage_count == 11){ if (life == 3){ drawTextureBox(1050, -1024, 128, 128, 0, 0, 128, 128, hp); drawTextureBox(1218, -1024, 128, 128, 0, 0, 128, 128, hp); drawTextureBox(1376, -1024, 128, 128, 0, 0, 128, 128, hp); } else if (life == 2){ drawTextureBox(1050, -1024, 128, 128, 0, 0, 128, 128, hp); drawTextureBox(1218, -1024, 128, 128, 0, 0, 128, 128, hp); } else if (life == 1){ drawTextureBox(1050, -1024, 128, 128, 0, 0, 128, 128, hp); } else { stage_count = 0; life = 3; x = -1500; y = -1024; break; } drawFillBox(-1024, -1024, 2048, 2048, Color(1, 1, 1, 1)); drawTextureBox(-40, 824, 100, 200, 0, 0, 256, 512, door); if (!(60 < x || -40 > x + 80 || 1024 < y || 824 > y + 160)){ drawTextureBox(-40, 824, 100, 200, 0, 0, 256, 512, door2); if (env.isPressKey(GLFW_KEY_SPACE)){ x = -40; y = -1024; stage_count++; nock.play(); } } if (env.isPressKey(GLFW_KEY_UP)){ y += 5; drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_back, Color(1,1,1, 1)); if (y > 864.0f){ y = 864.0f; } } else if (env.isPressKey(GLFW_KEY_LEFT)){ x -= 5; drawTextureBox(x, y, 80, 160, 0, 0, -256, 512, anb_side, Color(1, 1, 1, 1)); if (x < -1024.0f){ x = -40; y = -1024; } } else if (env.isPressKey(GLFW_KEY_DOWN)){ y -= 5; drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_top, Color(1, 1, 1, 1)); if (y < -1024.0f){ y = -1024.0f; } } else if (env.isPressKey(GLFW_KEY_RIGHT)){ x += 5; drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_side, Color(1, 1, 1, 1)); if (x > 944.0f){ x = -40; y = -1024; } } else { drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_top, Color(1, 1, 1, 1)); } drawFillCircle(x + 40, y + 80, 130, 130, 100, Color(0, 0, 0, 0.1)); drawFillBox(100, -1024, 300, 500, Color::white); if (!(400 < x || 100 > x + 80 || -524 < y || -1024 > y + 160)){ x = -40; y = -1024; life--; } drawFillBox(-1024, -1024, 800, 400, Color::white); if (!(-224 < x || -1024 > x + 80 || -624 < y || -1024 > y + 160)){ x = -40; y = -1024; life--; } drawFillBox(-600, -224, 1000, 300, Color::white); if (!(400 < x || -600 > x + 80 || -124 < y || -224 > y + 160)){ x = -40; y = -1024; life--; } drawFillBox(400, 70, 600, 300, Color::white); if (!(1100 < x || 400 > x + 80 || 370 < y || 70 > y + 160)){ x = -40; y = -1024; life--; } drawFillBox(-600, 24, 300, 300, Color::white); if (!(-300 < x || -600 > x + 80 || 324 < y || 300 > y + 160)){ x = -40; y = -1024; life--; } drawFillBox(-600, 524, 300, 200, Color::white); if (!(-300 < x || -600 > x + 80 || 724 < y || 524 > y + 160)){ x = -40; y = -1024; life--; } drawFillBox(-300, 524, 300, 100, Color::white); if (!(0 < x || -300 > x + 80 || 624 < y || 524 > y + 160)){ x = -40; y = -1024; life--; } drawFillBox(0, 350, 400, 276, Color::white); if (!(400 < x || 0 > x + 80 || 626 < y || 350 > y + 160)){ x = -40; y = -1024; life--; } } //-------------------------------------すてーじ2---------------------------------------- if (stage_count == 12){ if (life == 3){ drawTextureBox(1050, -1024, 128, 128, 0, 0, 128, 128, hp); drawTextureBox(1218, -1024, 128, 128, 0, 0, 128, 128, hp); drawTextureBox(1376, -1024, 128, 128, 0, 0, 128, 128, hp); } else if (life == 2){ drawTextureBox(1050, -1024, 128, 128, 0, 0, 128, 128, hp); drawTextureBox(1218, -1024, 128, 128, 0, 0, 128, 128, hp); } else if (life == 1){ drawTextureBox(1050, -1024, 128, 128, 0, 0, 128, 128, hp); } else { stage_count = 0; life = 3; x = -1500; y = -1024; akari_count = 0; break; } drawFillBox(-1024, -1024, 2048, 2048, Color(0, 0, 0, 1)); drawTextureBox(-40, 824, 100, 200, 0, 0, 256, 512, door); if (!(60 < x || -40 > x + 80 || 1024 < y || 824 > y + 160)){ drawTextureBox(-40, 824, 100, 200, 0, 0, 256, 512, door2); if (env.isPressKey(GLFW_KEY_SPACE)){ x = -40; y = -1024; stage_count++; akari_count = 0; nock.play(); } } if (env.isPressKey(GLFW_KEY_UP)){ y += 5; drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_back, Color(1, 1, 1, 1)); if (y > 864.0f){ y = 864.0f; } } else if (env.isPressKey(GLFW_KEY_LEFT)){ x -= 5; drawTextureBox(x, y, 80, 160, 0, 0, -256, 512, anb_side, Color(1, 1, 1, 1)); if (x < -1024.0f){ x = -40; y = -1024; } } else if (env.isPressKey(GLFW_KEY_DOWN)){ y -= 5; drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_top, Color(1, 1, 1, 1)); if (y < -1024.0f){ y = -1024.0f; } } else if (env.isPressKey(GLFW_KEY_RIGHT)){ x += 5; drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_side, Color(1, 1, 1, 1)); if (x > 944.0f){ x = -40; y = -1024; } } else { drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_top, Color(1, 1, 1, 1)); } drawFillBox(-1024, -1024, 800, 600, Color::black); if (!(-224<x ||-1024 >x + 80 ||-424 <y ||-1024 > y + 160)){ x = -40; y = -1024; life--; } drawFillBox(200, -1024, 500, 800, Color::black); if (!(700<x ||200 >x + 80 ||-224 <y || -1024> y + 160)){ x = -40; y = -1024; life--; } drawFillBox(-724, -250, 2000, 300, Color::black); if (!(1276<x || -724 >x + 80 || 50<y || -250> y + 160)){ x = -40; y = -1024; life--; } drawFillBox(-1024, 300, 1748, 200, Color::black); if (!(724<x ||-1024 >x + 80 ||500 <y ||300 > y + 160)){ x = -40; y = -1024; life--; } drawFillBox(60, 700, 1000, 424, Color::black); if (!(1060<x ||60 >x + 80 || 1124<y ||700 > y + 160)){ x = -40; y = -1024; life--; } akari_count++; if (akari_count < 90){ drawTextureBox(-50, -350, 64, 64, 0, 0, 64, 64, akari); } if (akari_count > 90 && akari_count < 180){ drawTextureBox(-900, -350, 64, 64, 0, 0, 64, 64, akari); } if (akari_count>180 && akari_count < 270){ drawTextureBox(-900, 150, 64, 64, 0, 0, 64, 64, akari); } if (akari_count>270 && akari_count < 360){ drawTextureBox(850, 150, 64, 64, 0, 0, 64, 64, akari); } if (akari_count>360 && akari_count < 450){ drawTextureBox(850, 550, 64, 64, 0, 0, 64, 64, akari); } if (akari_count>450 && akari_count < 540){ drawTextureBox(-40, 600, 64, 64, 0, 0, 64, 64, akari); } if (akari_count > 630){ akari_count = 0; } } //------------------------------------------すてーじ3---------------------------- if (stage_count == 13){ if (life == 3){ drawTextureBox(1050, -1024, 128, 128, 0, 0, 128, 128, hp); drawTextureBox(1218, -1024, 128, 128, 0, 0, 128, 128, hp); drawTextureBox(1376, -1024, 128, 128, 0, 0, 128, 128, hp); } else if (life == 2){ drawTextureBox(1050, -1024, 128, 128, 0, 0, 128, 128, hp); drawTextureBox(1218, -1024, 128, 128, 0, 0, 128, 128, hp); } else if (life == 1){ drawTextureBox(1050, -1024, 128, 128, 0, 0, 128, 128, hp); } else { stage_count = 0; life = 3; x = -40; y = -1024; akari_count = 0; break; } atari_count++; drawFillBox(-1024, -1024, 2048, 2048, Color(0, 0, 0, 1)); if (atari_count == 600){ if (!(1024 < x || -1024 > x + 80 || 1024 < y || -1024 > y + 160)){ x = -40; y = -1024; life--; } } if(atari_count > 600){ atari_count = 0; } drawTextureBox(-40, 824, 100, 200, 0, 0, 256, 512, door); if (!(60 < x || -40 > x + 80 || 1024 < y || 824 > y + 160)){ drawTextureBox(-40, 824, 100, 200, 0, 0, 256, 512, door2); if (env.isPressKey(GLFW_KEY_SPACE)){ x = -40; y = -1024; stage_count++; akari_count = 0; nock.play(); } } if (env.isPressKey(GLFW_KEY_UP)){ y += 5; drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_back, Color(1, 1, 1, 1)); if (y > 864.0f){ y = 864.0f; } } else if (env.isPressKey(GLFW_KEY_LEFT)){ x -= 5; drawTextureBox(x, y, 80, 160, 0, 0, -256, 512, anb_side, Color(1, 1, 1, 1)); if (x < -1024.0f){ x = -40; y = -1024; } } else if (env.isPressKey(GLFW_KEY_DOWN)){ y -= 5; drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_top, Color(1, 1, 1, 1)); if (y < -1024.0f){ y = -1024.0f; } } else if (env.isPressKey(GLFW_KEY_RIGHT)){ x += 5; drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_side, Color(1, 1, 1, 1)); if (x > 944.0f){ x = -40; y = -1024; } } else { drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_top, Color(1, 1, 1, 1)); } //----------------------------------------すてーじ14------------------------------- } if (stage_count == 14){ if (life == 3){ drawTextureBox(1050, -1024, 128, 128, 0, 0, 128, 128, hp); drawTextureBox(1218, -1024, 128, 128, 0, 0, 128, 128, hp); drawTextureBox(1376, -1024, 128, 128, 0, 0, 128, 128, hp); } else if (life == 2){ drawTextureBox(1050, -1024, 128, 128, 0, 0, 128, 128, hp); drawTextureBox(1218, -1024, 128, 128, 0, 0, 128, 128, hp); } else if (life == 1){ drawTextureBox(1050, -1024, 128, 128, 0, 0, 128, 128, hp); } else { stage_count = 0; life = 3; x = -1500; y = -1024; akari_count = 0; break; } drawFillBox(-1024, -1024, 2048, 2048, Color(1, 1, 1, 1)); drawTextureBox(-40, 824, 100, 200, 0, 0, 256, 512, door); if (!(60 < x || -40 > x + 80 || 1024 < y || 824 > y + 160)){ drawTextureBox(-40, 824, 100, 200, 0, 0, 256, 512, door2); if (env.isPressKey(GLFW_KEY_SPACE)){ x = -40; y = -1024; stage_count++; akari_count = 0; nock.play(); } } drawFillBox(-200, -300, 100, 100, Color::white); if (!(-100<x || -300 >x + 80 || -200 <y || -300 > y + 160)){ x = 100; y = -700; } drawFillBox(100, 0, 100, 100, Color::white); if (!(200<x || 100>x + 80 || 100<y || 0> y + 160)){ x = 300; y = -50; } drawFillBox(-500, -300, 100, 100, Color::white); if (!(-400<x || -500>x + 80 || -400 <y || -300 > y + 160)){ x = 200; y = -100; } drawFillBox(-700, -400, 100, 100, Color::white); if (!(-600<x || -700>x + 80 || -300<y || -400> y + 160)){ x = 700; y = -200; } drawFillBox(-500, -300, 100, 100, Color::white); if (!(-400<x || -500 >x + 80 || -400 <y || -300 > y + 160)){ x = 400; y = 500; } drawFillBox(300, 0, 100, 100, Color::white); if (!(400<x || 300>x + 80 || 100 <y || 0 > y + 160)){ x = -200; y = -900; } drawFillBox(-800, -300, 100, 100, Color::white); if (!(-700<x || -800 >x + 80 || -200 <y || -300> y + 160)){ x = -600; y = 300; } drawFillBox(-300, -400, 100, 100, Color::white); if (!(-200<x || -300 >x + 80 || -300 <y || -400> y + 160)){ x = -500; y = 800; } drawFillBox(300, 300, 100, 100, Color::white); if (!(400<x || 300>x + 80 || 400 <y || 300> y + 160)){ x = 900; y = -300; } drawFillBox(0, 600, 100, 100, Color::white); if (!(100<x || 0>x + 80 || 700 <y || 600> y + 160)){ x = 800; y = 700; } drawFillBox(700, 0, 100, 100, Color::white); if (!(800<x || 700 >x + 80 || 100 <y || 0> y + 160)){ x = -700; y = 800; } drawFillBox(500, -200, 100, 100, Color::white); if (!(600<x || 500 >x + 80 || -100 <y || -200 > y + 160)){ x = -400; y = 400; } drawFillBox(900, -400, 100, 100, Color::white); if (!(1000<x || 900 >x + 80 || 900<y || -400 > y + 160)){ x = -1000; y = 800; } drawFillBox(400, -600, 100, 100, Color::white); if (!(500<x || 400 >x + 80 || -500 <y || -600> y + 160)){ x = -200; y = -800; } drawFillBox(300, -800, 100, 100, Color::white); drawFillBox(500, -900, 100, 100, Color::white); if (!(600<x || 500 >x + 80 || -800 <y || -900> y + 160)){ x = 300; y = -50; } if (env.isPressKey(GLFW_KEY_UP)){ y += 5; drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_back, Color(1, 1, 1, 1)); if (y > 864.0f){ y = 864.0f; } } else if (env.isPressKey(GLFW_KEY_LEFT)){ x -= 5; drawTextureBox(x, y, 80, 160, 0, 0, -256, 512, anb_side, Color(1, 1, 1, 1)); if (x < -1024.0f){ x = -40; y = -1024; } } else if (env.isPressKey(GLFW_KEY_DOWN)){ y -= 5; drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_top, Color(1, 1, 1, 1)); if (y < -1024.0f){ y = -1024.0f; } } else if (env.isPressKey(GLFW_KEY_RIGHT)){ x += 5; drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_side, Color(1, 1, 1, 1)); if (x > 944.0f){ x = -40; y = -1024; } } else { drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_top, Color(1, 1, 1, 1)); } drawFillBox(-400, 400, 200, 824, Color::black); if (!(-200<x ||-400 >x + 80 ||600 <y ||400 > y + 160)){ x = -40; y = -1024; life--; } drawFillBox(200, 400, 200, 824, Color::black); if (!(400<x || 200>x + 80 ||1224 <y ||400 > y + 160)){ x = -40; y = -1024; life--; } drawFillBox(-100, 0, 200, 200, Color::black); if (!(100 < x || -100 > x + 80 || 200 < y || 0 > y + 160)) { x = -40; y = -1024; life--; } } //-------------------------------エンド画面------------------------------------------ if (stage_count == 15){ drawTextureBox(-1500, -1024, 3000, 2048, 0, 0, 4096, 2048, end); if (env.isPushButton(Mouse::LEFT)){ x = -1500; y = -1024; break; } } if (env.isPushKey(GLFW_KEY_CAPS_LOCK)){ stage_count++; } env.end(); } //ここまでが本編while if (!env.isOpen()){ return 0; } env.end(); } //*********************************************ここまで************************************** }
//used to generate display lists void generateDisplayLists() { treeList = glGenLists(1); glNewList(treeList, GL_COMPILE); int t; for(t=0; t< numTrees; t++) { int depth = rand() % 3 + 4; int angle = rand() % 30 + 30; glPushMatrix(); glTranslated(treeLocations[t][0],-10,treeLocations[t][1]); tree(depth, 5,100, 0,angle); glPopMatrix(); } glEndList(); cathedralList = glGenLists(1); glNewList(cathedralList, GL_COMPILE); //main cathedral archCustom(370,-9.9,450, 6,6,1, 270, 440,75, 150, insideArchTextures); archCustom(-370,-9.9,450, 6,6,1, 90, 440,75, 150, insideArchTextures); archCustom(0,440,-300, 6,6,1, 0, 1200,0, 150, insideArchTextures); archCustom(0,440,825, 6,6,1, 180, 450,0, 150, insideArchTextures); //roof of cathedral archCustom(370,440,450, 6.01,6.5,1, 270, 440,0, 150, outsideArchTextures); archCustom(-370,440,450, 6.01,6.5,1, 90, 440,0, 150, outsideArchTextures); archCustom(0,440,-300, 6.01,6.5,1, 0, 1200,0, 150, outsideArchTextures); archCustom(0,440,825, 6.01,6.5,1, 180, 450,0, 150, outsideArchTextures); //TO DO: FIX OVERLAP UNDERNEATH //front aisles cube(260,204.47,-250, 1099.5,1,227.75, 15,90, outsideArchTextures[1]); cube(-260,204.47,-250, 1099.5,1,227.75, 15,-90, outsideArchTextures[1]); cube(260,204.47,820, 439.5,1,227.75, 15,90, outsideArchTextures[1]); cube(-260,204.47,820, 439.5,1,227.75, 15,-90, outsideArchTextures[1]); drawAisleCompartment(-795,150, insideArchTextures, woodTexture); drawAisleCompartment(-575,150, insideArchTextures, woodTexture); drawAisleCompartment(-355,150, insideArchTextures, woodTexture); drawAisleCompartment(-135,150, insideArchTextures, woodTexture); drawAisleCompartment(85,150, insideArchTextures, woodTexture); //back aisles drawAisleCompartment(605,150, insideArchTextures, woodTexture); drawAisleCompartment(825,150, insideArchTextures, woodTexture); //doors on crossing aboveArch(-260, -10, 300, 4,2,1, 180, 55,35, 2.5, insideArchTextures); aboveArch(-480, -10, 300, 4,2,1, 180, 55,35, 2.5, insideArchTextures); door(-480, -10, 300, 4,2,1, 180, 55, woodTexture); aboveArch(260, -10, 300, 4,2,1, 180, 55,35, 2.5, insideArchTextures); aboveArch(480, -10, 300, 4,2,1, 180, 55,35, 2.5, insideArchTextures); door(480, -10, 300, 4,2,1, 180, 55, woodTexture); aboveArch(-260, -10, 600, 4,2,1, 0, 55,35, 2.5, insideArchTextures); aboveArch(-480, -10, 600, 4,2,1, 0, 55,35, 2.5, insideArchTextures); door(-480, -10, 600, 4,2,1, 0, 55, woodTexture); aboveArch(260, -10, 600, 4,2,1, 0, 55,35, 2.5, insideArchTextures); aboveArch(480, -10, 600, 4,2,1, 0, 55,35, 2.5, insideArchTextures); door(480, -10, 600, 4,2,1, 0, 55, woodTexture); //altar cube(0,-10.1,830, 300,2.5,450, 0,0, woodTexture); cube(0,-7.5,700, 50,10,20, 0,0, altarTexture); cube(0,2.5,700, 60,2.5,30, 0,0, altarTexture); glEndList(); naveAisleList= glGenLists(1); glNewList(naveAisleList, GL_COMPILE); glEndList(); towerList = glGenLists(1); glNewList(towerList, GL_COMPILE); //front towers tower(0,515,-900, 300,150,400,100, 0, insideArchTextures[0],outsideArchTextures[1]); tower(260.1,-10.1,-875, 220,500,475,150, 0, insideArchTextures[0],outsideArchTextures[1]); tower(-260.1,-10.1,-875, 220,500,475,150, 0, insideArchTextures[0],outsideArchTextures[1]); archCustom(0,-250,-900, 5,2,1, 0, 100,200, 0, insideArchTextures); aboveArch(0, -10, -850, 5,2,1, 0, 80,27.5, 5, insideArchTextures); aboveArch(0, -10, -950, 5,2,1, 180, 80,27.5, 5, insideArchTextures); aboveArch(0, 275, -850, 5,2,1, 0, 80,27.5, 5, insideArchTextures); aboveArch(0, 275, -950, 5,2,1, 180, 80,27.5, 5, insideArchTextures); door(0, -10, -850, 5,2,1, 0, 80, woodTexture); door(0, -10, -950, 5,2,1, 180, 80, woodTexture); //back towers tower(0,-10,1180, 300,675,400,250, 0, insideArchTextures[0],outsideArchTextures[1]); tower(260.1,-10.1,1185, 220,675,300,300, 0, insideArchTextures[0],outsideArchTextures[1]); tower(-260.1,-10.1,1185, 220,675,300,300, 0, insideArchTextures[0],outsideArchTextures[1]); //left tower tower(640,-10.1,450, 350,675,300,100, 90, insideArchTextures[0],outsideArchTextures[1]); //right tower tower(-640,-10.1,450, 350,675,300,100, 90, insideArchTextures[0],outsideArchTextures[1]); glEndList(); pew = LoadOBJ("pew.obj"); pewList = glGenLists(1); glNewList(pewList, GL_COMPILE); glColor4f(0.289,0.160,0.082,1); int pewX; int pewZ; for(pewX=35; pewX <=110; pewX += 25) { for(pewZ=-300; pewZ <= 240; pewZ +=15) { adjustList(pewX,-10,pewZ, 2,2,2, 180,pew); adjustList(-1*pewX,-10,pewZ, 2,2,2, 180,pew); } } glEndList(); floorList = glGenLists(1); glNewList(floorList, GL_COMPILE); glColor4f(0.868,0.805,0.699,1); glBindTexture(GL_TEXTURE_2D, tileTexture); glBegin(GL_QUADS); glNormal3d(0,1,0); glTexCoord2f(0.0,0.0); glVertex3d(-370.0,-9.9,-950.0); glTexCoord2f(0.0,193.5); glVertex3d(-370.0,-9.9,1035.0); glTexCoord2f(74.0,193.5); glVertex3d(370.0,-9.9,1035.0); glTexCoord2f(74.0,0.0); glVertex3d(370.0,-9.9,-950.0); glNormal3d(0,1,0); glTexCoord2f(0.0,0.0); glVertex3d(-600.0,-9.9,300.0); glTexCoord2f(0.0,30.0); glVertex3d(-600.0,-9.9,600.0); glTexCoord2f(120.0, 30.0); glVertex3d(600.0,-9.9,600.0); glTexCoord2f(120.0, 0.0); glVertex3d(600.0,-9.9,300.0); glEnd(); glEndList(); crossList = glGenLists(1); glNewList(crossList, GL_COMPILE); cube(0,100,1000, 5,100,5, 0,0, woodTexture); cube(0,175,1000, 75,5,5, 0,0, woodTexture); glEndList(); }
int main(int, char const**) { // Create the main window sf::RenderWindow window(sf::VideoMode(TILE_WIDTH*28, TILE_WIDTH*31), "PAC MAN"); window.setFramerateLimit(FRAME_RATE); // Set the Icon sf::Image icon; if (!icon.loadFromFile(resourcePath() + "icon.png")) { return EXIT_FAILURE; } window.setIcon(icon.getSize().x, icon.getSize().y, icon.getPixelsPtr()); // Try to open the given texture sf::Texture tileset_texture; if (!tileset_texture.loadFromFile(resourcePath() + "data/full_texture_x3.png")) { return EXIT_FAILURE; } // More importantly, let's generate our tileset from that texture. AssetManager assetManager(TILE_WIDTH); std::map<sf::String, sf::Sprite> spriteSet = assetManager.generateSpriteSet(&tileset_texture); std::map<sf::String, PacTile*> tileSet; PacTile outer_top_left_corner(spriteSet["outer_top_left_corner"], "WALL"); tileSet["outer_top_left_corner"] = &outer_top_left_corner; PacTile weird_north_left_corner(spriteSet["weird_north_left_corner"], "WALL"); tileSet["weird_north_left_corner"] = &weird_north_left_corner; PacTile weird_west_upper_corner(spriteSet["weird_west_upper_corner"], "WALL"); tileSet["weird_west_upper_corner"] = &weird_west_upper_corner; PacTile weird_east_upper_corner(spriteSet["weird_east_upper_corner"], "WALL"); tileSet["weird_east_upper_corner"] = &weird_east_upper_corner; PacTile weird_west_lower_corner(spriteSet["weird_west_lower_corner"], "WALL"); tileSet["weird_west_lower_corner"] = &weird_west_lower_corner; PacTile weird_east_lower_corner(spriteSet["weird_east_lower_corner"], "WALL"); tileSet["weird_east_lower_corner"] = &weird_east_lower_corner; PacTile box_top_left_corner(spriteSet["box_top_left_corner"], "WALL"); tileSet["box_top_left_corner"] = &box_top_left_corner; PacTile top_right_corner(spriteSet["top_right_corner"], "WALL"); tileSet["top_right_corner"] = &top_right_corner; PacTile weird_north_right_corner(spriteSet["weird_north_right_corner"], "WALL"); tileSet["weird_north_right_corner"] = &weird_north_right_corner; PacTile box_top_right_corner(spriteSet["box_top_right_corner"], "WALL"); tileSet["box_top_right_corner"] = &box_top_right_corner; PacTile bottom_right_corner(spriteSet["bottom_right_corner"], "WALL"); tileSet["bottom_right_corner"] = &bottom_right_corner; PacTile box_bottom_right_corner(spriteSet["box_bottom_right_corner"], "WALL"); tileSet["box_bottom_right_corner"] = &box_bottom_right_corner; PacTile bottom_left_corner(spriteSet["bottom_left_corner"], "WALL"); tileSet["bottom_left_corner"] = &bottom_left_corner; PacTile box_bottom_left_corner(spriteSet["box_bottom_left_corner"], "WALL"); tileSet["box_bottom_left_corner"] = &box_bottom_left_corner; PacTile top_edge(spriteSet["top_edge"], "WALL"); tileSet["top_edge"] = &top_edge; PacTile box_top_edge(spriteSet["box_top_edge"], "WALL"); tileSet["box_top_edge"] = &box_top_edge; PacTile left_edge(spriteSet["left_edge"], "WALL"); tileSet["left_edge"] = &left_edge; PacTile inner_left_edge(spriteSet["inner_left_edge"], "WALL"); tileSet["inner_left_edge"] = &inner_left_edge; PacTile right_edge(spriteSet["right_edge"], "WALL"); tileSet["right_edge"] = &right_edge; PacTile inner_right_edge(spriteSet["inner_right_edge"], "WALL"); tileSet["inner_right_edge"] = &inner_right_edge; PacTile bottom_edge(spriteSet["bottom_edge"], "WALL"); tileSet["bottom_edge"] = &bottom_edge; PacTile box_bottom_edge(spriteSet["box_bottom_edge"], "WALL"); tileSet["box_bottom_edge"] = &box_bottom_edge; // House tiles! PacTile house_top_right_corner(spriteSet["house_top_right_corner"], "WALL"); tileSet["house_top_right_corner"] = &house_top_right_corner; PacTile house_bottom_right_corner(spriteSet["house_bottom_right_corner"], "WALL"); tileSet["house_bottom_right_corner"] = &house_bottom_right_corner; PacTile house_top_left_corner(spriteSet["house_top_left_corner"], "WALL"); tileSet["house_top_left_corner"] = &house_top_left_corner; PacTile house_bottom_left_corner(spriteSet["house_bottom_left_corner"], "WALL"); tileSet["house_bottom_left_corner"] = &house_bottom_left_corner; PacTile door(spriteSet["door"], "WALL"); tileSet["door"] = &door; PacTile floor(spriteSet["floor"], "FLOOR"); tileSet["floor"] = &floor; // Load up the map! Map map(sf::Vector2<double>(0, 0), sf::Vector2<int>(28, 31), TILE_WIDTH); map.configureMap(tileSet); // Create a graphical text to display /*sf::Font font; if (!font.loadFromFile(resourcePath() + "sansation.ttf")) { return EXIT_FAILURE; } // Load a music to play sf::Music music; if (!music.openFromFile(resourcePath() + "nice_music.ogg")) { return EXIT_FAILURE; }*/ // Declare the ghosts! Pinky pinky(sf::Vector2<double>(0, 0), "HOME"); Blinky blinky(sf::Vector2<double>(0, 0), "HOME"); Inky inky(sf::Vector2<double>(0, 0), "HOME"); Sue sue(sf::Vector2<double>(0, 0), "HOME"); // Game variables // Assemble the PacMan! PacMan pacman(1, 1, 1, 60, map); std::vector<sf::Sprite> pacUpSprites; std::vector<sf::Sprite> pacDownSprites; std::vector<sf::Sprite> pacLeftSprites; std::vector<sf::Sprite> pacRightSprites; pacUpSprites.push_back(spriteSet["pacUp0"]); pacUpSprites.push_back(spriteSet["pacUp1"]); pacUpSprites.push_back(spriteSet["pacUp2"]); pacUpSprites.push_back(spriteSet["pacUp1"]); pacDownSprites.push_back(spriteSet["pacDown0"]); pacDownSprites.push_back(spriteSet["pacDown1"]); pacDownSprites.push_back(spriteSet["pacDown2"]); pacDownSprites.push_back(spriteSet["pacDown1"]); pacLeftSprites.push_back(spriteSet["pacLeft0"]); pacLeftSprites.push_back(spriteSet["pacLeft1"]); pacLeftSprites.push_back(spriteSet["pacLeft2"]); pacLeftSprites.push_back(spriteSet["pacLeft1"]); pacRightSprites.push_back(spriteSet["pacRight0"]); pacRightSprites.push_back(spriteSet["pacRight1"]); pacRightSprites.push_back(spriteSet["pacRight2"]); pacRightSprites.push_back(spriteSet["pacRight1"]); pacman.setUpSprites(pacUpSprites, 4); pacman.setDownSprites(pacDownSprites, 4); pacman.setLeftSprites(pacLeftSprites, 4); pacman.setRightSprites(pacRightSprites, 4); pacman.setVelocity(sf::Vector2<double>(0.0, 1.0)); pacman.initialize("RIGHT"); // Play the music // music.play(); // Start the game loop while (window.isOpen()) { // Process events sf::Event event; while (window.pollEvent(event)) { // Close window: exit if (event.type == sf::Event::Closed) { window.close(); } // Escape pressed: exit if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Escape) { window.close(); } } pacman.update(map); // DRAWING THE SCREEN window.clear(); // Draw the map drawMap(&window, map); // Then, draw any pellets / fruits, those type things // Then, draw the ghosts // Then, draw pacman window.draw(pacman.getSprite()); // Update the window window.display(); } return EXIT_SUCCESS; }
/* ORIGINAL 0-00 OFFSET: 8007ED4C */ u32 CScriptDoor::GetDoorOpenCondition(CStateManager& mgr) { const TCastToPtr<CScriptDock> dock = mgr.ObjectById(x282_dockId); if (!dock) return 2; if (x25c_animTime < 0.05f || x2a8_30_doClose) return 1; TAreaId destArea = dock->GetAreaId(); if (destArea < 0 || destArea >= mgr.GetWorld()->GetNumAreas()) return 0; if (!mgr.GetWorld()->GetAreaAlways(destArea)->IsPostConstructed()) return 1; if (!mgr.GetWorld()->AreSkyNeedsMet()) return 1; TAreaId connArea = mgr.GetWorld() ->GetAreaAlways(dock->GetAreaId()) ->GetDock(dock->GetDockId()) ->GetConnectedAreaId(dock->GetDockReference(mgr)); if (connArea == kInvalidAreaId) return 0; const CWorld* world = mgr.GetWorld(); const CGameArea* area = world->GetAreaAlways(connArea); if (!area->IsPostConstructed()) { mgr.SendScriptMsg(dock, GetUniqueId(), EScriptObjectMessage::SetToMax); return 1; } if (area->GetPostConstructed()->x113c_playerActorsLoading != 0) return 1; for (CEntity* ent : mgr.GetPlatformAndDoorObjectList()) { TCastToPtr<CScriptDoor> door(ent); if (!door || door->GetUniqueId() == GetUniqueId()) continue; if (door->GetAreaIdAlways() == GetAreaIdAlways() && door->x2a8_25_wasOpen) { if (door->x282_dockId != kInvalidUniqueId) return 1; } } for (const CGameArea& aliveArea : *world) { if (aliveArea.GetAreaId() == area->GetAreaId()) continue; if (!aliveArea.IsFinishedOccluding()) return 1; } // if (area->TryTakingOutOfARAM()) { if (world->GetMapWorld()->IsMapAreasStreaming()) return 1; } return 2; }