WorldRpgMaking
Vous souhaitez réagir à ce message ? Créez un compte en quelques clics ou connectez-vous pour continuer.

WorldRpgMaking

Un forum basé sur le logiciel de création : Rpg Maker XP
 
AccueilRechercherDernières imagesS'enregistrerConnexion
Le Deal du moment : -20%
Ecran PC GIGABYTE 28″ LED M28U 4K ( IPS, 1 ms, ...
Voir le deal
399 €

 

 Jeu morpion

Aller en bas 
2 participants
AuteurMessage
Sword-anto
Posteur intégré
Posteur intégré
Sword-anto


Messages : 61
Date d'inscription : 15/12/2007
Age : 31
Localisation : Quelque pars ^^

Jeu morpion Empty
MessageSujet: Jeu morpion   Jeu morpion Icon_minitimeDim 16 Déc - 1:01

Faire le mini-jeu "Morpion"

Auteur : Shado

Fonction : ¨Permet de jouer au morpion (en québécois : Tictactoe).

Principe : Aligner horizontalement, verticalement ou diagonalement 3 croix ou 3 rond pour gagner

Image(s) : Aucune

Ressource(s) : Aucune

Remarque : Non testé.

Nombre de scripts : 1

Installation : Ouvrez l'éditeur de scripts (F11) et créez un nouveau script au dessus de "Main" et nommez le "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 :

Code:
$scene = Tictactoe.new

Et voila le script :

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
paturaux
Nouveau posteur
Nouveau posteur



Messages : 3
Date d'inscription : 10/07/2008

Jeu morpion Empty
MessageSujet: Re: Jeu morpion   Jeu morpion Icon_minitimeJeu 10 Juil - 21:10

Le scrip marche mais lol tu joue tous seul ^^ c'est toi qui met les rond et les croix donc a force sa devient ennuyeux.
Revenir en haut Aller en bas
 
Jeu morpion
Revenir en haut 
Page 1 sur 1

Permission de ce forum:Vous ne pouvez pas répondre aux sujets dans ce forum
WorldRpgMaking :: RPG Maker XP :: Les Scripts :: Autres Scripts-
Sauter vers:  
Ne ratez plus aucun deal !
Abonnez-vous pour recevoir par notification une sélection des meilleurs deals chaque jour.
IgnorerAutoriser