Accueil du SiteAccueil du Site  AccueilAccueil  Dernières imagesDernières images  RechercherRechercher  ConnexionConnexion  S'enregistrerS'enregistrer  



-34%
Le deal à ne pas rater :
-34% LG OLED55B3 – TV OLED 4K 55″ 2023 – 100Hz HDR 10+, ...
919 € 1399 €
Voir le deal

Partagez
 

 Mini-jeu: Morpion/Tictactoe

Voir le sujet précédent Voir le sujet suivant Aller en bas 
AuteurMessage
Elekami
Fondateur
Fondateur
Elekami

Masculin
Messages postés : 19071
Date d'inscription : 19/07/2008
Jauge LPC :
Mini-jeu: Morpion/Tictactoe 8915271400100 / 100100 / 100Mini-jeu: Morpion/Tictactoe 8915271400

Mini-jeu: Morpion/Tictactoe Pater_10
Mini-jeu: Morpion/Tictactoe Staffe10
Mini-jeu: Morpion/Tictactoe Mythe_10
Mini-jeu: Morpion/Tictactoe Membre11
Mini-jeu: Morpion/Tictactoe Doyen10
Mini-jeu: Morpion/Tictactoe Scanar10
Mini-jeu: Morpion/Tictactoe Compos10
Mini-jeu: Morpion/Tictactoe Testeu10
Mini-jeu: Morpion/Tictactoe Membre15
Mini-jeu: Morpion/Tictactoe Partag10
Mini-jeu: Morpion/Tictactoe Projet10
Mini-jeu: Morpion/Tictactoe Projet16
Mini-jeu: Morpion/Tictactoe Riche_10
Mini-jeu: Morpion/Tictactoe Travai10
Mini-jeu: Morpion/Tictactoe Collec10
Mini-jeu: Morpion/Tictactoe Collec11
Mini-jeu: Morpion/Tictactoe Collec12
Mini-jeu: Morpion/Tictactoe Collec13
Mini-jeu: Morpion/Tictactoe Connar10


Mini-jeu: Morpion/Tictactoe Empty
MessageSujet: Mini-jeu: Morpion/Tictactoe   Mini-jeu: Morpion/Tictactoe EmptyMer 23 Juin 2010 - 13:07

Permet de faire un mini-jeu, le morpion (ou tic tac toe).

Auteur: Shado



Ouvrez l'éditeur de scripts et créez un nouveau script au dessus de Main, nommez ce nouveau script "Tic-tac-toe" et collez le code ci-dessous

Utilisation : Appeler le mini-jeu grâce à la commande d'évènement "Insérer un script" et mettez ce code :

$scene = Tictactoe.new


Code:

######################################
# Jeu Tic-tac-toe fait par Shado - 27 Juillet 2006
# Laissez un crédit pour moi si vous l'utilisez. Merci !
# Version : 1.3
######################################

class Tictactoe

  @@turn = "x"
  @@font_name = "Arial"
  @@font_size = 40
 
  def initialize(menu_index = 0)
    @menu_index = menu_index
  end
######################
  def main
  @turnWindow = Turn_Window.new(@@turn)
  @turnWindow.x = 450
  @turnWindow.y = 370
  setSquares
  setMenu
 
  Graphics.transition
  loop do
    Graphics.update
    Input.update
    update
    if $scene != self
    break
    end
  end

  Graphics.freeze
  @command_window.dispose
  @turnWindow.dispose
 
  for x in 0..8
    @sqr[x].dispose
  end
  end
######################
  def update
    @command_window.update
    @turnWindow.update(@@turn)
 
    for x in 0..8
    @sqr[x].update
    end
 
  if @command_window.active
      update_command
      return
  end
  end
 
######################
  def update_command
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Map.new
      return
    end
    if Input.trigger?(Input::C)
      case @command_window.index
      when 0..8
        $game_system.se_play($data_system.decision_se)
        doAction(@command_window.index)
      when 9
        $game_system.se_play($data_system.decision_se)
        $scene = Tictactoe.new
      when 10
        $game_system.se_play($data_system.cancel_se)
        $scene = Scene_Map.new
      end
      return
    end
  end
######################
def setMenu
  s1 = "Haut gauche"
  s2 = "Haut milieu"
  s3 = "Haut droit"
  s4 = "Centre gauche"
  s5 = "Centre milieu"
  s6 = "Centre droit"
  s7 = "Bas left"
  s8 = "Bas milieu"
  s9 = "Bas droit"
  s10 = "Redémarrer"
  s11 = "Quitter"
  @command_window = Window_Command.new(175, [s1, s2, s3, s4, s5, s6,s7,s8,s9,s10,s11])
  @command_window.index = @menu_index
  @command_window.x = 440
end
######################
def setSquares
  @sqr = []
  for x in 0..2
    @sqr[x] = Square.new(@@font_name,@@font_size)
    @sqr[x].x = (x+1)*100
    @sqr[x].y = 50
  end
 
  for x in 3..5
    @sqr[x] = Square.new(@@font_name,@@font_size)
    @sqr[x].x = (x-2)*100
    @sqr[x].y = 150
  end
 
  for x in 6..8
    @sqr[x] = Square.new(@@font_name,@@font_size)
    @sqr[x].x = (x-5)*100
    @sqr[x].y = 250
  end
 
end
######################
def doAction(squareId)
  if (@sqr[squareId].getOwner == "none")
    @sqr[squareId].setOwner(@@turn)
    verifyScore
  else
    $game_system.se_play($data_system.buzzer_se)
  end
end
######################
def verifyScore
  gameIsFinish = false
  #check all --
  for x in 0..2
    if (@sqr[x*3].getOwner == @@turn && @sqr[x*3+1].getOwner == @@turn && @sqr[x*3+2].getOwner == @@turn)
      print "Les "+@@turn+" a gagné !"
      gameIsFinish = true
    end
  end
 
  #check all |
  for x in 0..2
    if (@sqr[x].getOwner == @@turn && @sqr[x+3].getOwner == @@turn && @sqr[x+6].getOwner == @@turn)
      print "Les "+@@turn+" a gagné !"
      gameIsFinish = true
    end
  end
 
  #check \
  if (@sqr[0].getOwner == @@turn && @sqr[4].getOwner == @@turn && @sqr[8].getOwner == @@turn)     
    print "Les "+@@turn+" a gagné !"
    gameIsFinish = true
  end
 
  #check /
  if (@sqr[2].getOwner == @@turn && @sqr[4].getOwner == @@turn && @sqr[6].getOwner == @@turn)
    print "Les "+@@turn+" a gagné !"
    gameIsFinish = true
  end
 
  if noMoreSpace && !gameIsFinish
    print "Match nul!"
    $scene = Scene_Restart.new
  end
 
  if gameIsFinish
    $scene = Scene_Restart.new
  elsif (@@turn == "x")
    @@turn = "o"
  else @@turn = "x"
  end
end
######################
def noMoreSpace
  for x in 0..8
    if (@sqr[x].getOwner == "none")
      return false
    end
  end
  return true
end
######################
end

#----------------------------------------------------------------------
#Squares
#----------------------------------------------------------------------
class Square < Window_Base
 
  def initialize(fontName,fontSize)
    @owner = "none"
   
    super(0, 0, 100,100)
    self.contents = Bitmap.new(width-32, height-32)
    self.contents.font.name = fontName 
    self.contents.font.size = fontSize
    refresh
  end
 
  def refresh
    self.contents.clear
    if (@owner == "x")
      self.contents.font.color = text_color(2)
      self.contents.draw_text(22, 15, 100, 32, "X")
    elsif (@owner == "o")
      self.contents.font.color = text_color(1)
      self.contents.draw_text(22, 15, 100, 32, "O")
    end
  end
 
  def update
    refresh
  end
#############
  def setOwner(newOwner)
    @owner = newOwner
  end
#############
  def getOwner
    return @owner
  end
#############
end

#----------------------------------------------------------------------
#Turn Window
#----------------------------------------------------------------------
class Turn_Window < Window_Base
 
  def initialize(turn)
    super(0, 0, 165,60)
    self.contents = Bitmap.new(width-32, height-32)
    self.contents.font.name = "Arial" 
    self.contents.font.size = 30
    refresh(turn)
  end
 
  def refresh(turn)
    self.contents.clear
    if (turn == "x")
      self.contents.font.color = text_color(2)
      self.contents.draw_text(0,0,100,32,"Tour de : X")
    elsif
      self.contents.font.color = text_color(1)
      self.contents.draw_text(0,0,100,32,"Tour de : O")
    end
  end
 
  def update(turn)
    refresh(turn)
  end
end
#----------------------------------------------------------------------
#scene restart
#----------------------------------------------------------------------
class Scene_Restart
 
  @@font_name = "Arial"
  @@font_size = 40
 
  def initialize(menu_index = 0)
    @menu_index = menu_index
  end
######################
  def main
    setMenu
   
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end

    Graphics.freeze
    @command_window.dispose
  end
######################
  def update
    @command_window.update
 
    if @command_window.active
        update_command
        return
    end
  end
######################
  def update_command
    if Input.trigger?(Input::C)
      case @command_window.index
      when 0
        $game_system.se_play($data_system.decision_se)
        $scene = Tictactoe.new
      when 1
        $game_system.se_play($data_system.cancel_se)
        $scene = Scene_Map.new
      end
      return
    end
  end
###################### 
  def setMenu
    s1 = "Redémarrer Tic-tac-toe"
    s2 = "Quitter"
    @command_window = Window_Command.new(180, [s1, s2])
    @command_window.index = @menu_index
    @command_window.x = 250
    @command_window.y = 200
  end
end
Revenir en haut Aller en bas
https://www.ledijonshow.fr https://twitter.com/EleKoptes
 
Mini-jeu: Morpion/Tictactoe
Voir le sujet précédent Voir le sujet suivant Revenir en haut 
Page 1 sur 1
 Sujets similaires
-
» Super Mini Map ^^
» [XP] Mini-jeu Noël
» BESTIMETABLE (mini-jeu)
» [Mini-Jeu] Le Gamix !
» [Mini-Tuto] Les Feedback

Permission de ce forum:Vous ne pouvez pas répondre aux sujets dans ce forum
Le Palais Créatif :: ~ PARTAGE ~ :: Scripts et plugins :: RPG Maker XP :: Autres-
Sauter vers: