కోడ్‌జిమ్/జావా కోర్సు/జావా కలెక్షన్స్/పెద్ద పని: సోకోబాన్ వ్రాయండి

పెద్ద పని: సోకోబాన్ వ్రాయండి

అందుబాటులో ఉంది

"హలో, సైనికుడు!"

"హలో, కెప్టెన్ ఉడుతలు, సార్!"

"అభినందనలు. ఈ రోజు మనకు సెలవు ఉంది."

"మరి మనం ఏమైనా చేయగలమా?"

"అవును, అమిగో. మీరు రోజంతా మీ బొమ్మలతో ఆడుకోవచ్చు. ఉదాహరణకు, సోకోబాన్. చిన్నప్పటి నుండి నాకు ఇష్టమైన ఆట. నేను 435 స్థాయిని దాటలేను. మీరు సహాయం చేయగలరా?"

"అయితే, నేను సహాయం చేస్తాను, నేను మీకు చూపిస్తాను, కెప్టెన్."

కెప్టెన్ స్క్విరెల్స్ తన జేబులో నుండి పాత గేమ్ బాయ్‌ని తీసి సోకోబాన్ మోనోక్రోమ్ వెర్షన్‌ను ప్రారంభించాడు. కానీ అప్పుడు నిరాశ ఉంది. బ్యాటరీ అయిపోతుంది మరియు గేమ్ బాయ్ షట్ డౌన్ అవుతుంది.

నిశ్శబ్దంగా, కెప్టెన్ గేమ్ బాయ్ వైపు, ఆ తర్వాత అమిగో వైపు, మళ్లీ గేమ్ బాయ్ వైపు చూస్తున్నాడు. అటూ ఇటూ తిరుగుతూ మెల్లగా తన ఆఫీసుకి నడిచాడు.

"కెప్టెన్! సోకోబాన్ యొక్క మన స్వంత సంస్కరణను వ్రాస్దాం! మేము 1000 అదనపు స్థాయిలను పెంచుతాము మరియు చక్కని గ్రాఫికల్ ఇంటర్‌ఫేస్‌ను తయారు చేస్తాము."

"అమిగో, మీరు నన్ను ఆశ్చర్యపరచడం మానేయరు. ఏజెంట్ IntelliJ IDEAని సంప్రదించండి. అతను మీ కోసం ఇతర అసైన్‌మెంట్‌లు ఏవీ లేకుంటే మరియు అతని సెలవు రోజున మీకు సహాయం చేయాలనుకుంటే, కొనసాగండి."

పెద్ద పని: సోకోబాన్ - 1 వ్రాయండి
20
టాస్క్
Java Collections,  స్థాయిపాఠం
లాక్ చేయబడింది
Sokoban (part 1)
Today we're going to write our own implementation of the game Sokoban. This is a logical puzzle game. You can read more about it on Wikipedia. The game will consist of 3 main components (as you may have guessed, you'll need the MVC pattern). The graphical interface will be implemented using Swing.
10
టాస్క్
Java Collections,  స్థాయిపాఠం
లాక్ చేయబడింది
Sokoban (part 2)
The foundation is laid, so now let's start building. You can think of the gameplay as the interaction of GameObject objects. We'll have several types of them: Box, StorageLocation (the place where you need to put the box), Wall, and Player. 2.1. Add an abstract GameObject class to the model package
10
టాస్క్
Java Collections,  స్థాయిపాఠం
లాక్ చేయబడింది
Sokoban (part 3)
Soon we'll be creating various game objects. It would be handy to be able to draw them somewhere right away and see how they look. Objects will be drawn on the game board represented by a Board object. You've received modified code for the View class that creates a Board object and sets up the view
20
టాస్క్
Java Collections,  స్థాయిపాఠం
లాక్ చేయబడింది
Sokoban (part 4)
We already have a shared GameObject class. It's time to create classes for specific types of game objects. 4.1. Some game objects can move (player and boxes) and some can't (walls and storage locations). 4.1.1. Add the Movable interface to the model package. 4.1.2. The Movable interface must have a
20
టాస్క్
Java Collections,  స్థాయిపాఠం
లాక్ చేయబడింది
Sokoban (part 5)
Box and Player game objects can not only collide with other objects, but also move around the board. 5.1. Create a Player class and a Box class in the model package. Make each of them inherit the most appropriate class. 5.2. The created classes must support the interface responsible for object move
10
టాస్క్
Java Collections,  స్థాయిపాఠం
లాక్ చేయబడింది
Sokoban (part 6)
It's time to create the StorageLocation class. This class will be responsible for the game board cells that all the boxes must be moved to. Objects of this type must not move across the board or collide with other game objects. 6.1. Add a StorageLocation class to the model package. 6.2. The class m
10
టాస్క్
Java Collections,  స్థాయిపాఠం
లాక్ చేయబడింది
Sokoban (part 7)
Let's make the Wall class. A wall can collide with other objects, but it can't move. 7.1. Add a Wall class to the model package. 7.2. Make the class inherit the appropriate parent class. 7.3. Implement a constructor with int x and int y parameters. 7.4. Implement the method for drawing. Hint: you c
10
టాస్క్
Java Collections,  స్థాయిపాఠం
లాక్ చేయబడింది
Sokoban (part 8)
You've created the complete collection of game objects. Let's create a class to store these objects. 8.1. Create a GameObjects class in the model package. 8.2. Add the following: 8.2.1. Set walls, Set boxes, Set storageLocations, and Player player fields. 8.2.2. Getters
10
టాస్క్
Java Collections,  స్థాయిపాఠం
లాక్ చేయబడింది
Sokoban (part 9)
Various events will occur during the game. Let's create an EventListener interface. Every class that wants to handle events must implement it. And classes that generate events will call this interface's methods. 9.1. Add the EventListener interface to the controller package. 9.2. Add these void met
20
టాస్క్
Java Collections,  స్థాయిపాఠం
లాక్ చేయబడింది
Sokoban (part 10)
The game will have several levels, and all of them will be stored in a text file. Now we'll write a LevelLoader test stub. Why a test stub? We don't need the full functionality yet. It's pretty complicated, so we'll leave it for later. For now: 10.1. Create a LevelLoader class in the model package.
20
టాస్క్
Java Collections,  స్థాయిపాఠం
లాక్ చేయబడింది
Sokoban (part 11)
Let's begin fleshing out the Model class' functionality. Add the following: 11.1. A GameObjects gameObjects field. It will store our game objects. 11.2. An int currentLevel field that stores the current level. Initialize it to 1. 11.3. A LevelLoader levelLoader field that stores the level loader. I
20
టాస్క్
Java Collections,  స్థాయిపాఠం
లాక్ చేయబడింది
Sokoban (part 12)
Let's try organizing the interaction between the view and model. 12.1. Add an update() method to the View class. It must call the repaint() method on the board field. In other words, the update() method will update the view (redraw the board). 12.2. Add the GameObjects getGameObjects() method to th
20
టాస్క్
Java Collections,  స్థాయిపాఠం
లాక్ చేయబడింది
Sokoban (part 13)
Let's fill out the controller's functionality. 13.1. In addition to what the Controller class constructor already has, add event listeners on the model and view. The controller must itself be a listener. 13.2. Implement the controller's methods: 13.2.1. move(Direction direction) - should call the m
20
టాస్క్
Java Collections,  స్థాయిపాఠం
లాక్ చేయబడింది
Sokoban (part 14)
Let's make our game more interactive (using a keyboard to move the player). We'll start by handling keystrokes. 14.1. Add to the Board class a nested KeyHandler class that inherits KeyAdapter. 14.2. Overload its keyPressed() method. If the key with code VK_LEFT is pressed, then send an event with a
40
టాస్క్
Java Collections,  స్థాయిపాఠం
లాక్ చేయబడింది
Sokoban (part 15)
The time has come to implement the model's move() method, which is responsible for movement. But first, let's implement some helper methods. Add the following methods to the Model class: 15.1. boolean checkWallCollision(CollisionObject gameObject, Direction direction). This method checks for collis
20
టాస్క్
Java Collections,  స్థాయిపాఠం
లాక్ చేయబడింది
Sokoban (part 16)
All that remains is to finish implementing the level loader. 16.1. Open the levels.txt file and carefully study the file structure. The character 'X' represents a wall, ‘*’ represents a box, ‘.’ represents a storage location, ‘&’ represents a box in a storage location, and ‘@’ represents the player
10
టాస్క్
Java Collections,  స్థాయిపాఠం
లాక్ చేయబడింది
Sokoban (part 17)
You're a superstar! You've made a great game. Now you can relax a bit and play it. If you ever get tired of it, which is practically impossible, you could make the following improvements: 17.1. Use images to represent the objects. 17.2. Make a level editor. 17.3. Add rankings. You could even post t
వ్యాఖ్యలు
  • జనాదరణ పొందినది
  • కొత్తది
  • పాతది
వ్యాఖ్యానించడానికి మీరు తప్పనిసరిగా సైన్ ఇన్ చేసి ఉండాలి
ఈ పేజీకి ఇంకా ఎలాంటి వ్యాఖ్యలు లేవు