Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Mini-games

Comments in 'Plugin Development' started by picker118, May 28, 2015.

  1. Xenturio
    Offline

    Xenturio Active Member

    Joined:
    Sep 19, 2014
    Posts:
    333
    Minecraft User:
    Xenturio
    this is what i mean... thank u ;)

    btw if someone have a better idea please drop it here ^^
  2. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    :). I hope you understand what I mean ;)
  3. Xenturio
    Offline

    Xenturio Active Member

    Joined:
    Sep 19, 2014
    Posts:
    333
    Minecraft User:
    Xenturio
    yes i understand and can recode it by myself =)
    Legoboy0215 likes this.
  4. Xenturio
    Offline

    Xenturio Active Member

    Joined:
    Sep 19, 2014
    Posts:
    333
    Minecraft User:
    Xenturio
    btw i like the easy idea... i think about to write players in a second array but why... your idea is so easy xD and if
    we have more player then setted spawnpositions i can easy count the player and spawnposition array and start at beginning by first position xD
  5. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    :). Now we are going a bit off-topic.
  6. TigerHix
    Offline

    TigerHix Active Member

    Joined:
    May 11, 2015
    Posts:
    61
    Minecraft User:
    TigerHix
    As a Bukkit minigame developer for years, though there are minor differences between Bukkit API and PocketMine API, but if anyone is willing to make a minigame-type plugin, here's my advice: just start coding it.

    Really, it's my honest opinion. By the processing of development, you would learn which parts are needed for coding a minigame. At first, you would code everything in one or two classes. At this state, your objective is simply to make it "work". No bugs, lag-free, playable, or better, fun. Your code could be a total mess and everything is coupled, but it is fine.

    To proceed to next step, you will have to know some concepts of OOP. After you familiarize with concepts such as abstraction, you will start to realize the problems with your initial code. You will start to split the code into different classes to have them follow the Single Responsibility Principle. For example, you are writing a Survival Games plugin. You will have a Match class for handling the join/leave/start/end events, an Arena class for storing the spawnpoints of the SG map, a CustomPlayer class extending Player class for storing extra variables (equipments? spectating or not?) of a SG player. By interacting with each other, you should now have a working minigame plugin with clean, readable code.

    What's next? Now let's say you make quite a few minigames right now. You made Survival Games, you made Spleef, you made Hide n Seek. All of them follows the above structure I mentioned: having classes like Match, Arena or CustomPlayer. But you would soon realize that most of the code you wrote is repetitive. Why? Because all minigames share the same basic components. The code for broadcasting join/leave messages is same; the code for respawning a player automatically is same; the code for resetting a player's status is same. Think deeper, you will realize more similarities on game logic.

    Let's use actual code to demonstrate. This is the previous code:

    PHP:
    class SurvivalGamesMatch {

        public function 
    join(Player $player) {
            
    // ...
        
    }

        public function 
    fillChests() {
            
    // Fill all chests with items
        
    }

        
    // More methods

    }
    PHP:
    class SpleefMatch {

        public function 
    join(Player $player) {
            
    // ...
        
    }

        public function 
    rollbackArena() {
            
    // Rollback all blocks that are "spleefed" by players
        
    }

        
    // More methods

    }
    PHP:
    class HideNSeekMatch {

        public function 
    join(Player $player) {
            
    // ...
        
    }

        public function 
    disguise(Player $player$blockId) {
            
    // Disguise a player as block
        
    }

        
    // More methods

    }
    Right? You spot the similarities. Now refactor the code.

    PHP:
    class Match {

        public function 
    join(Player $player) {
            
    // ...
        
    }

        
    // More methods

    }
    PHP:
    class SurvivalGamesMatch extends Match {

        public function 
    fillChests() {
            
    // Fill all chests with items
        
    }

        
    // More methods

    }
    PHP:
    class SpleefMatch extends Match {

        public function 
    rollbackArena() {
            
    // Rollback all blocks that are "spleefed" by players
        
    }

        
    // More methods

    }
    PHP:
    class HideNSeekMatch extends Match {

        public function 
    join(Player $player) {
            
    // Want to do some extra operations on player? Simply override the method
            
    parent::join($player);
            
    $player->sendMessage("Welcome to Hide n Seek!");
        }

        public function 
    disguise(Player $player$blockId) {
            
    // Disguise a player as block
        
    }

        
    // More methods

    }
    Perhaps you feel disdain with me using paragraphs to explain OOP but not "how to make a minigame". But honestly, if you want your minigame plugins to be high-quality and easy for maintenance, above are my honest suggestions. If you have followed above steps, you would have developed a minigame framework. The framework could also contain utilities for miscellaneous features that is not belonged to game logic. Hence, you could easily develop minigame using the framework, and if you found any bug in the framework, fix it, and you got the bug fixed in all your framework-based minigames. The large portion of code reused also greatly decreases the time on developing a new minigame.

    Following is a part of the structure of my own framework for PocketMine, which I recently ported from my Bukkit one.

    [​IMG]
    [​IMG]

    It is still in development, though you might have already figured out how would it work by looking the file names. :p I will make it open-source sooner or later, but of course it will be far better if you write one yourself. In that way, you will have more control on the code, and it's always more fun to write something huge from scratch.

    Anyway, I will be glad if those experience could help anybody. Good luck on making your own minigame.
    CrazedMiner, Primus and PEMapModder like this.
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Nice design
    Legoboy0215 and TigerHix like this.
  8. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Excuse me for bumping another old thread but this is worth to. @TigerHix could you make tutorial? It's sad that I found this structure/idea/plan/design too late.
  9. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,130
    Plugins:
    4
    Minecraft User:
    iksaku
    You must have a structured thinking in order to make your own minigames, like any other plugin, just be sure that you understand your own methods.
    CrazedMiner, Primus and HotFireyDeath like this.
  10. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    I have no problem with structured thinking except my ideas come faster than I can capture so I prefer to hold onto one design. When I was making my first mini-game I didn't had any design in my mind yet so I experimented a lot, what isn't that bad but that's really time consuming.
  11. Nawaf_Craft1b
    Offline

    Nawaf_Craft1b Active Member Plugin Developer

    Joined:
    May 8, 2015
    Posts:
    232
    Plugins:
    1
    Minecraft User:
    Nawaf_Craft1b
  12. DC4CODE
    Offline

    DC4CODE Active Member

    Joined:
    Nov 19, 2015
    Posts:
    64
    Minecraft User:
    dxdsc9349
  13. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    I just pointed out that @TigerHix code is worth enough to be shown in tutorial :D
  14. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Just start it. Push yourself to think there is a deadline so no extra features. In my school, we have a scientific engineering process. I just found out the last 3 works for software engineering too. Plan - Create - Improve.
    Primus likes this.

Share This Page

Advertisement