Jump to content
Rpg²S Forum

*Gioco del tris


the-joker
 Share

Recommended Posts

Descrizione

Script per inserire il gioco del Tris.

 

Autore

Shado

 

Istruzioni per l'uso

Create una nuova classe sopra main e chiamatela Tictactoe.
Inserite il codice e per richiamarlo usare il call script con questo: $scene = Tictactoe.new .

Script

 

 

 

######################################
# 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 = "Alto a sinistra"
		s2 = "Alto al centro"
		s3 = "Alto a destra"
		s4 = "Centro a sinistra"
		s5 = "Centro al centro"
		s6 = "Centro a destra"
		s7 = "Basso a sinistra"
		s8 = "Basso al centro"
		s9 = "Basso a destra"
		s10 = "Resetta"
		s11 = "Esci"
		@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 " "+@@turn+" Fine !"
				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 " "+@@turn+" Fine !"
				gameIsFinish = true
			end
		end
		
		#check \
		if (@sqr[0].getOwner == @@turn && @sqr[4].getOwner == @@turn && @sqr[8].getOwner == @@turn)
			print " "+@@turn+" Fine !"
			gameIsFinish = true
		end
		
		#check /
		if (@sqr[2].getOwner == @@turn && @sqr[4].getOwner == @@turn && @sqr[6].getOwner == @@turn)
			print " "+@@turn+" Fine !"
			gameIsFinish = true
		end
		
		if noMoreSpace && !gameIsFinish
			print "Niente!"
			$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 = "Ricomincia Tris"
		s2 = "Esci"
		@command_window = Window_Command.new(180, [s1, s2])
		@command_window.index = @menu_index
		@command_window.x = 250
		@command_window.y = 200
	end
end

 

 

 

 

Bugs e Conflitti noti

N/A

"Quarantadue!" urlò Loonquawl. "Questo è tutto ciò che sai dire dopo un lavoro di sette milioni e mezzo di anni?"

"Ho controllato molto approfonditamente," disse il computer, "e questa è sicuramente la risposta. Ad essere sinceri, penso che il problema sia che voi non abbiate mai saputo veramente qual è la domanda."

 

 

 

Gioco disponibile: Prophecy of Last Era - OPEN SOURCE

 

http://www.mediafire.com/?u6aut42ks12ixgf

 

Puoi utilizzare qualsiasi evento, mappa, chara, grafica, e programmazione contenuta nel gioco-demo.

Nessun diritto di copia.

Hope you enjoy.

http://www.rpg2s.net/awards/bestmusician3.jpg

Link to comment
Share on other sites

Si infatti..Dai, fai che il pc giochi..magari sposti piu' a sinistra il tetris e ci metti la figura di una bella figliola che gioca contro di te!!! :sisi: :rovatfl:

http://www.freankexpo.net/signature/1129.png

2986.png

BIM_Banner3.png

Premi RpgMaker

 


http://www.rpg2s.net/forum/uploads/monthly_01_2017/msg-293-0-48316500-1483794996.jpghttp://www.rpg2s.net/dax_games/r2s_regali2.pngContesthttp://rpg2s.net/gif/SCContest1Oct.gifhttp://rpg2s.net/gif/SCContest3Oct.gifhttp://rpg2s.net/gif/SCContest2Oct.gifhttp://rpg2s.net/gif/SCContest3Oct.gifhttp://rpg2s.net/gif/SCContest3Oct.gifhttp://rpg2s.net/gif/SCContest3Oct.gifhttp://rpg2s.net/gif/SCContest2Oct.gifhttp://rpg2s.net/gif/SCContest3Oct.gifhttp://rpg2s.net/gif/SCContest1Oct.gifhttp://rpg2s.net/gif/SCContest2Oct.gif http://rpg2s.net/gif/SCContest1Oct.gif http://rpg2s.net/gif/SCContest2Oct.gif http://rpg2s.net/gif/SCContest2Oct.gifhttp://rpg2s.net/gif/SCContest1Oct.gifhttp://www.rpg2s.net/awards/bestpixel2.jpghttp://www.rpg2s.net/awards/bestresourCSist2.jpghttp://www.rpg2s.net/awards/mostproductive1.jpghttp://i42.servimg.com/u/f42/13/12/87/37/iconap13.pnghttp://i42.servimg.com/u/f42/13/12/87/37/iconap14.pnghttp://i42.servimg.com/u/f42/13/12/87/37/iconap15.pnghttp://i42.servimg.com/u/f42/13/12/87/37/iconap16.pnghttp://i42.servimg.com/u/f42/13/12/87/37/screen10.pnghttp://www.rpgmkr.net/contest/screen-contest-primo.pnghttp://www.makerando.com/forum/uploads/jawards/iconawards3.png

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...