- ZarbyMembre
- Nombre de messages : 71
Age : 35
Distinction : aucune
Date d'inscription : 15/12/2011
CardGame Minigame
Lun 26 Aoû 2013 - 1:33
Information :
Createur : Zarby
Version : 1.0
Credit : Non requis
Il n'utilise aucun graphic et est customizable (plus dans les prochaine version)
Utilisation :
Copier coller le script au dessus du script Main
Vous pouvez configurer les options en haut du script comme la couleurr, variables, icon utiliser, animation, ect
Description du jeu dans le haut du script
et apeller un script dans un event :
Script:
comme dit sur rpgmakervx.net j'ai pas le temp cette semaine pour completer le script, d'ici la semaine prochaine il va être traduit en francais, code plus claire et beaucoup plus customizable et probablement porté sur VXACE.
Createur : Zarby
Version : 1.0
Credit : Non requis
Il n'utilise aucun graphic et est customizable (plus dans les prochaine version)
Utilisation :
Copier coller le script au dessus du script Main
Vous pouvez configurer les options en haut du script comme la couleurr, variables, icon utiliser, animation, ect
Description du jeu dans le haut du script
et apeller un script dans un event :
- Code:
$scene = Scene_CardGame.new
- Spoiler:
Script:
- Spoiler:
- Code:
#==============================================================================
#* Game Information
#-----------------------------------------------------------------------------
# - Made by Zarby
# - No Graphics Required (But customizable) and Animated
# - No Credit Required
# - V1.0
#
# When the game start it distribute 5 "monsters" cards to player and computer
# 3 Numbers appear on this cards Attack, Defense and Life of the monsters
# a random player is choosed to start, the goal of the game is to defeat
# the computer card with your card the default formula is :
#Life = (Life - (Attack x 5) - Defense)
#when all card are played there is a timer of 2 sec by default between each attack
#card are placed from left to right when you defeat a card all card at the right of this card is shifted on the left
#==============================================================================
#* Game Settings
#----------------------------------------------------------------------------
#This minigame use database monsters for cards set monsters range here (10minimum) Avoid too much to avoid lag
Min_monster_range = 1
Max_monster_range = 20
#Multiple use of same card turn it to true if you want unlimited number replica
Multiple_card_use = false #Not Working Yet
#Graphics Part :
Attack_Icon_Id = 8
Life_Icon_Id = 64
Defense_Icon_Id = 52
#For colors you can use paint as reference Select color and modify color and you have Red,Green,Blue,Alpha Optional
#Color.new(R,G,B(,optional)A)
Background_Face_Card_Color = Color.new(230,240,220)
Face_Card_Edge1_Color = Color.new(50,80,30) # The Outline of the card
Face_Card_Edge2_Color = Color.new(180,220,155) # One line after the outline
Face_Card_Edge3_Color = Color.new(210,230,200) # Two line after the outline
Background_Back_Card_Color = Color.new(45,65,40)
Back_Card_Edge1_Color = Color.new(210,230,200)
Back_Card_Edge2_Color = Color.new(175,210,155)
Back_Card_Edge3_Color = Color.new(45,65,40)
Background_Card_Socket_Color = Color.new(120,110,75)
Light_Card_Socket_Color = Color.new(180,170,130)
Dark_Card_Socket_Color = Color.new(70,60,40)
Font_Attack_Color = Color.new(210,30,10)
Font_Defense_Color = Color.new(45,125,180)
Font_Life_Color = Color.new(70,220,30)
Animation_Attack_Id = 7
#Music & Sound Part :
#Not Done Yet.
#Others :
#Returning variable to know who win Return 0 if we lose and Return 1 if we win and 2 if Draw
Returning_Variable = 20
Timer_Between_Each_Attack = 60
Timer_Between_Each_Round = 150
#Add Shuffle for array not included in the Rpg Maker Ruby version
class Array
# Standard in Ruby 1.8.7+. See official documentation[http://ruby-doc.org/core-1.9/classes/Array.html]
def shuffle
dup.shuffle!
end unless method_defined? :shuffle
# Standard in Ruby 1.8.7+. See official documentation[http://ruby-doc.org/core-1.9/classes/Array.html]
def shuffle!
size.times do |i|
r = i + Kernel.rand(size - i)
self[i], self[r] = self[r], self[i]
end
self
end unless method_defined? :shuffle!
end
#==============================================================================
# ** Window_CardGame
#------------------------------------------------------------------------------
# This window displays the sockets and playeds cards
#==============================================================================
class Window_CardGame < Window_Base
def initialize
super(0, 0, 544, 416)
self.back_opacity = 0
self.opacity = 0
self.z = -10
@socket = create_socket_bitmap
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.blt(32,108,@socket,@socket.rect)
self.contents.blt(32,196,@socket,@socket.rect)
self.contents.blt(104,108,@socket,@socket.rect)
self.contents.blt(104,196,@socket,@socket.rect)
self.contents.blt(176,108,@socket,@socket.rect)
self.contents.blt(176,196,@socket,@socket.rect)
self.contents.blt(248,108,@socket,@socket.rect)
self.contents.blt(248,196,@socket,@socket.rect)
self.contents.blt(320,108,@socket,@socket.rect)
self.contents.blt(320,196,@socket,@socket.rect)
self.contents.blt(392,152,@socket,@socket.rect)
end
def dispose
super
@socket.dispose
end
#--------------------------------------------------------------------------
# * Creation of the Card Socket Bitmap
#--------------------------------------------------------------------------
def create_socket_bitmap
bmp = Bitmap.new(64,80)
bmp.fill_rect(0, 0, 64, 80, Background_Card_Socket_Color)
bmp.fill_rect(0, 0, 64, 1, Dark_Card_Socket_Color)
bmp.fill_rect(0, 0, 1, 80, Dark_Card_Socket_Color)
bmp.fill_rect(0, 79, 64, 1, Light_Card_Socket_Color)
bmp.fill_rect(63, 0, 1, 80, Light_Card_Socket_Color)
return bmp
end
end
#==============================================================================
# ** Monster_Card
#------------------------------------------------------------------------------
# This class Create a monster Card
#==============================================================================
class Monster_Card
attr_reader :atk
attr_reader :def
attr_reader :hp
#--------------------------------------------------------------------------
# * Initialize processing
#--------------------------------------------------------------------------
def initialize(x,y,monsterid)
@sprite = Sprite.new()
@sprite.x = x
@sprite.y = y
@monsterid = monsterid
@hp = $data_enemies[@monsterid].maxhp
@atk = $data_enemies[@monsterid].atk
@def =$data_enemies[@monsterid].def
@bitmap = create_card_bitmap
@sprite.z = -5
@sprite.bitmap = Bitmap.new(64,80)
@sprite.bitmap.blt(0,0,@bitmap,Rect.new(64,0,64,80))
@uncovering = false
@uncovered = false
@uncoveredcpu = false
@moving = false
@movingtimer = 0
@uncoveredx = 64
@uncoveredw = 64
@disposed = false
@destx = x
@desty = y
@speedx = 0.0
@speedy = 0.0
@x = x
@y = y
@sprite.x = x
@sprite.y = y
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
if @disposed == false
if @uncovering == true
if @uncovered == false
@uncoveredw -= 2
if @uncoveredw <= 0
@uncoveredw = 0
@uncoveredx = 0
@uncovered = true
end
else
@uncoveredw += 4
if @uncoveredw >= 64
@uncoveredw = 64
@uncoveredx = 0
@uncovering = false
@uncoveredcpu = true
end
end
@sprite.bitmap = Bitmap.new(64,80)
@sprite.bitmap.clear
@sprite.bitmap.blt(0,0,@bitmap,Rect.new(@uncoveredx ,0,@uncoveredw ,80))
end
if @moving = true
if @movingtimer > 0
@x = @x + @speedx
@y = @y + @speedy
else
@x = @destx
@y = @desty
@moving = false
end
@sprite.x = @x
@sprite.y = @y
@movingtimer = @movingtimer -1
end
end
end
def dispose
@bitmap.dispose
@sprite.dispose
@disposed = true
end
def movey_instant(y)
@desty = y
@y = y
@sprite.y = y
@moving = true
end
def moveto(x,y)
@speedx = ((x-@x) /50).to_f
@speedy = ((y-@y) /50).to_f
@destx = x
@desty = y
@movingtimer = 50
@moving = true
end
def set_life(hp)
@hp = hp
@bitmap = create_card_bitmap
@sprite.bitmap.clear
@sprite.bitmap.blt(0,0,@bitmap,Rect.new(0,0,64,80))
end
def uncover
if @uncoveredcpu == false
@uncovering = true
end
end
#--------------------------------------------------------------------------
# * Termination Processing
#--------------------------------------------------------------------------
def terminate
super
end
def create_card_bitmap
end
#--------------------------------------------------------------------------
# * Creation of the Card Bitmap
#--------------------------------------------------------------------------
def create_card_bitmap
bmp = Bitmap.new(128,80)
bmp.fill_rect(0, 0, 64, 80, Face_Card_Edge1_Color )
bmp.fill_rect(1, 1, 62, 78, Face_Card_Edge2_Color )
bmp.fill_rect(2, 2, 60, 76, Face_Card_Edge3_Color )
bmp.fill_rect(3, 3, 58, 74, Background_Face_Card_Color)
bmp.fill_rect(64, 0, 64, 80, Back_Card_Edge1_Color )
bmp.fill_rect(65, 1, 62, 78, Back_Card_Edge2_Color )
bmp.fill_rect(66, 2, 60, 76, Back_Card_Edge3_Color )
bmp.fill_rect(67, 3, 58, 74, Background_Back_Card_Color)
temp_bmp = Cache.battler($data_enemies[@monsterid].battler_name,$data_enemies[@monsterid].battler_hue)
bmp.stretch_blt(Rect.new(4,4,56,72),temp_bmp,temp_bmp.rect)
temp_bmp = Cache.system("Iconset")
rect = Rect.new(Attack_Icon_Id % 16 * 24, Attack_Icon_Id / 16 * 24, 24, 24)
bmp.blt(0,0,temp_bmp,rect)
rect = Rect.new(Life_Icon_Id % 16 * 24, Life_Icon_Id / 16 * 24, 24, 24)
bmp.blt(0,26,temp_bmp,rect)
rect = Rect.new(Defense_Icon_Id % 16 * 24, Defense_Icon_Id / 16 * 24, 24, 24)
bmp.blt(0,52,temp_bmp,rect)
bmp.font.color = Font_Attack_Color
bmp.draw_text(24,0, 40, 24, @atk)
bmp.font.color = Font_Life_Color
bmp.draw_text(24, 26, 40, 24, @hp)
bmp.font.color = Font_Defense_Color
bmp.draw_text(24, 52, 40, 24, @def)
return bmp
end
end
#==============================================================================
# ** Scene_CardGame
#------------------------------------------------------------------------------
# This class allow you to play a card game
#==============================================================================
class Scene_CardGame < Scene_Base
#--------------------------------------------------------------------------
# * Start processing
#--------------------------------------------------------------------------
def start
super
@main_window = Window_CardGame.new()
@card = []
for i in Min_monster_range..Max_monster_range do
@card.push(Monster_Card.new(408.0,168.0,i))
end
@card = @card.shuffle
@computer_timer = Timer_Between_Each_Attack
@automatic = false
@automatic_timer = 60
@distribution_timer = 30
@distribution_done = false
@uncover_done = false
@card_index = 0
@player_card_index = 0
@computer_card_index = 0
@player_cards = []
@computer_cards = []
@card_uncover_timer = 20
@played_cards_player = []
@played_cards_computer = []
@selected_card_index = 0
@player_turn = true
@playing_card = false
@automatic_index = 0
@automatic_round_timer = Timer_Between_Each_Round
@animation = Sprite_Base.new
@animation2 = Sprite_Base.new
@animation.x = 80
@animation.y = 165
@animation2.x = 80
@animation2.y = 252
#@animation.animation(1,true)
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
@animation.update
@animation2.update
@card.each do |i|
i.update
end
if @distribution_done == false
@distribution_timer -= 1
if (@distribution_timer <= 0)
if @card_player == false
@card[@card_index].moveto(32 +( (@card_index/2) * 72),8)
@computer_cards.push(@card[@card_index])
@card_player = true
else
@card[@card_index].moveto(32 +( (@card_index/2) * 72),416-88)
@player_cards.push(@card[@card_index])
@card_player = false
end
@card_index += 1
if @card_index == 10
@distribution_done = true
end
@distribution_timer = 30
end
end
if @uncover_done == false
if @distribution_done == true
@card_uncover_timer -= 1
if (@card_uncover_timer <= 0)
@player_cards[@player_card_index].uncover
@player_card_index +=1
if @player_card_index == 5
@uncover_done = true
selected_index_change
end
@card_uncover_timer = 20
end
end
end
if (@uncover_done == true) and (@distribution_done == true)
if Input.trigger?(Input::LEFT)
@selected_card_index -=1
if (@selected_card_index == -1)
@selected_card_index = @player_cards.size-1
end
selected_index_change
end #LEFT END
if Input.trigger?(Input::RIGHT)
@selected_card_index +=1
if (@selected_card_index == @player_cards.size)
@selected_card_index = 0
end
selected_index_change
end # RIGHT END
if (@player_turn == true)
if Input.trigger?(Input::C)
if @player_cards.size > 0
@played_cards_player.push(@player_cards.delete_at(@selected_card_index))
@played_cards_player[@played_cards_player.size-1].moveto((48+(72*(@played_cards_player.size-1))).to_f,212.0)
@selected_card_index = 0
selected_index_change
@player_turn = false
end
end
end #Player Turn END
if @player_turn == false
@computer_timer -=1
if @computer_timer <= 0
if @computer_cards.size > 0
@computer_card_index = -1
#check wich card is strongest than player if there no play index 0
@computer_cards.each_with_index do |i,ind|
if i.atk > @played_cards_player[@played_cards_player.size-1].atk
@computer_card_index = ind
end
end
if (@computer_card_index == -1)
@computer_card_index = 0
end
@played_cards_computer.push(@computer_cards.delete_at(@computer_card_index))
@played_cards_computer[@played_cards_computer.size-1].moveto((48+(72*(@played_cards_computer.size-1))).to_f,125.0)
@played_cards_computer[@played_cards_computer.size-1].uncover
@player_turn = true
@computer_timer = 120
end
end#Computer Turn END
if @automatic == false
if @player_cards.size == 0 and @computer_cards.size == 0
@automatic = true
end
end
end#Uncover & Distribution END
end # ??? END
#Damage Things Here
if (@automatic == true)
@automatic_round_timer-=1
if @automatic_round_timer <= 0
if @animation.animation?
@automatic_timer = Timer_Between_Each_Attack
end
@automatic_timer -=1
if @automatic_timer <= 0
@animation.x = ((48+32)+(72*(@automatic_index)))
@animation2.x = ((48+32)+(72*(@automatic_index)))
if (@played_cards_computer[@automatic_index] != nil) and (@played_cards_player[@automatic_index] != nil)
@animation.start_animation($data_animations[Animation_Attack_Id])
@animation2.start_animation($data_animations[Animation_Attack_Id])
#Life = (Life - (Attack x 5) - Defense) + 5% chance of critical (attack x10)
@played_cards_computer[@automatic_index].set_life(@played_cards_computer[@automatic_index].hp-((@played_cards_player[@automatic_index].atk * 5) - @played_cards_computer[@automatic_index].def))
@played_cards_player[@automatic_index].set_life(@played_cards_player[@automatic_index].hp-((@played_cards_computer[@automatic_index].atk * 5) - @played_cards_player[@automatic_index].def))
end
@automatic_index+=1
if (@played_cards_computer.size == 0) and (@played_cards_player.size == 0)
#Draw
$game_variables[Returning_Variable] = 2
terminate
end
if (@played_cards_computer.size == 0)
#Player Win
$game_variables[Returning_Variable] = 1
terminate
end
if @played_cards_player.size == 0
#Player Lose
$game_variables[Returning_Variable] = 0
terminate
end
if (@automatic_index == 5)
@automatic_round_timer = Timer_Between_Each_Round
@card.each do |i|
if i.hp <= 0
i.dispose
@played_cards_player.delete(i)
@played_cards_computer.delete(i)
end
end
@played_cards_computer.each_with_index do |i,ind|
i.moveto((48+(72*(ind))).to_f,125.0)
end
@played_cards_player.each_with_index do |i,ind|
i.moveto((48+(72*(ind))).to_f,212.0)
end
@automatic_index = 0
end#index = 5
end
end
end
end # Update END
def selected_index_change
@player_cards.each_with_index do |i,ind|
if (ind != @selected_card_index)
i.movey_instant(416-88)
else
i.movey_instant(416-100)
end
end
end
#--------------------------------------------------------------------------
# * Termination Processing
#--------------------------------------------------------------------------
def terminate
super
@card.each do |i|
i.dispose
end
@animation.dispose
@animation2.dispose
#@main_window.dispose
$scene = Scene_Map.new()
end
end
comme dit sur rpgmakervx.net j'ai pas le temp cette semaine pour completer le script, d'ici la semaine prochaine il va être traduit en francais, code plus claire et beaucoup plus customizable et probablement porté sur VXACE.
- Elisa'Staffeux retraité
- Nombre de messages : 2924
Age : 26
Localisation : Par là-bas !
Distinction : Mon héritière que je chéris
[Coco' ]
Plus que 2 ans avant d'épouser Coco' ! Compte à rebours lancé !
[Auto-distinction]
Adepte du "Je le savais" alors qu'elle le savait pas.
Date d'inscription : 30/05/2009
Re: CardGame Minigame
Lun 26 Aoû 2013 - 11:33
Merci pour le script, il est plutôt sympa, une fois plus customisable il sera vraiment cool.
+5 points de participation
+5 points de participation
- faller-magieMembre
- Nombre de messages : 873
Age : 30
Localisation : Diubdal, France.
Distinction : aucune
Date d'inscription : 20/02/2012
Re: CardGame Minigame
Lun 26 Aoû 2013 - 13:22
Un mini yugioh pourquoi pas après tout.. x)
Merci du script Zarbi. (non le script n'est pas zarbi..)
Merci du script Zarbi. (non le script n'est pas zarbi..)
- nithisMembre
- Nombre de messages : 258
Age : 29
Localisation : Belgique
Distinction : Master Show 2012
Date d'inscription : 01/03/2012
Re: CardGame Minigame
Ven 30 Aoû 2013 - 13:31
Ce script à énormément de potentiel, continue de le travailler et il sera juste superbe, j'aimerai beaucoup l'utiliser. =)
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum