Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Can someone please help me make some windows?

OS

Sponsor

As some of you may know, I am writing a new Battle System for fans of Trading Card Games. It seems that a few windows will be required to all the player to understand how cards work. I, personally a System Scripter, have little experience with windows, and I tend to screw up all of my window scripts severely (which is why I never released the Lock Pick System, Alchemy 2.0xa System, Interact Menu Deluxe+, or any other system that needed windows.)

I just need two window classes right now: Duelist_Window and Data_Window.

The Duelist Window is a small window that shows the amount of cards left in the Deck, the life points left, and the Duelist's name. This window should be completely horizontal, with the parameters (duelist, pos = 0), where duelist is the duelist and pos is either 0 or 1.

If pos == 0, then the window should sit on the bottom of the screen. If it equals 1, then the window should rest at the top like a Help Window.

Here are methods of class Duelist so that you can use them in the script;
Code:
name, gets the Duelist's name.
life, gets the duelist's life.
cards_in_deck, returns the amount of cards in the deck.

As for the Data_Window class, it must be large enough to hold a 180x330 card graphic. The parameters for the window are (graphic, pos = 0), where graphic is the directory of the graphic, and pos is the position of the window (0 means left side of the screen in the middle, 1 means the right side of the screen in the middle.)

Any help would be much appreciated, and credit will be given.

Peace!
 
Do you still need help on windows? I might be able to help during my leisure time (hope I can get it more...), if no one is willing to do so.

First of all, can you draw sketches of those windows (using Paint maybe)? Or some examples of what would them show?

If you want to make your own window, maybe you'd like to try Window-Scene Wizard, an interactive GUI-based (using RMXP "game" but acts much like an IDE; mouse and keyboard-controlled) wizard to make windows. You can find it here, or if lost, tell me and I'll send the whole "game". Well, the behavior of the window created by this still must be hard-coded though...

Good luck with your project. Anyway, if your TCG has finished, would you mind to share your script? I'd like to merge some TCG system into my DBS (would that be possible? :))
 

OS

Sponsor

Thanks for replying. Honestly, I forgot about the W&S Wizard (Which I have already downloaded a few times...). It was never perfect, and caused many errors when I didn't do something perfectly right. I'll try that again, though.

As for the state of the TCG, I am on the verge of quitting it. I have run into strange errors, and I have little support on the project. If you like, I can give you what I do have, but it isn't perfect.

Code:
module OS
  module TCG
    #=Data======================================================================
    # Data
    MaxHand = 7
    MaxDeck = 120
    MinHand = 1 # If greater than 0, duelist will draw until they have this many
                # cards if their Hand is under this value.
    MaxLife = 10000
    StartLife = 5000
    MinLife = 0 # If Life reaches this, the duelist fails.
    FieldWidth = 5
    FieldHieght = 2
    #=ID Custom Tags============================================================
    # Commands:
    Atk  = 0   # Attack Opponent
    Dfn  = 1   # Block Attack
    Set  = 3   # Set Card on Field (Face Down)
    Play = 4   # Set Card on Field (Face Up)
    Tap  = 5   # Tap a card on the field
    Draw = 6   # Draw a card from the Deck
    ResG = 7   # Restore a card from the Grave to the Field
    Rem  = 8   # Remove a card from the Duel entirely
    ResR = 9   # Restore a card from Removed to the Field
    TapO = 10  # Tap an Opponent's card on the Field
    Grav = 11  # Send a card to the Grave
    ToHn = 12  # Send a card to its owner's hand
    ToDk = 13  # Send a card to its owner's deck
    # Targets:
    MonS   = 0 # User's Monster
    MonO   = 1 # Opponent's Monster
    SplS   = 2 # User's Spell
    SplO   = 3 # Opponent's Spell
    ItmS   = 4 # User's Item
    ItmO   = 5 # Opponent's Item
    UsHn   = 6 # User's Hand
    OpHn   = 7 # Opponent's Hand
    RndHnS = 8 # Random Card from User's Hand
    RndHnO = 9 # Random Card from Opponent's Hand
    UsDk   = 10 # User's Deck
    OpDk   = 11 # Opponent's Deck
    RndDkS = 12 # Random Card from User's Deck
    RndHnO = 13 # Random Card from Opponent's Deck
    RndMnS = 14 # Random Monster from the User's Field
    RndMnO = 15 # Random Monster from the Opponent's Field
    RndSpS = 16 # Random Spell from the User's Field
    RndSpO = 17 # Random Spell from the Opponent's Field
    RndItS = 18 # Random Item from the User's Field
    RndItO = 19 # Random Item from the Opponent's Field
    # Target Attributes:
      # Atk and Dfn will work here as well!
    # Status:
    NoDuel  = 0 # All cards not in a duel have this stat! (slot 0)
    InHand  = 1 # Card is in a Hand (slot 1)
    InDeck  = 2 # Card is in a Deck (slot 1)
    OnField = 3 # Card is on the Field (slot 1)
    Removed = 4 # Removed from play (slot 1)
    Altered = 5 # Atk, Dfn, and/or Effects have been altered (slot 2)
    inGrave = 6 # Card is in a Grave (slot 1)
    #=Label Custom Tags=========================================================
    # Card Types:
    Monster = "Creature"
    Spell   = "Spell"
    Item    = "Equipment"
    # Elements:
    Fire   = "Pyro"
    Water  = "Aqua"
    Stone  = "Terra"
    Plant  = "Gaia"
    Soul   = "Spirit"
    Undead = "Cursed"
    # Attributes:
    Attack = "Atk Power"
    Defend = "Dfn Power"
  end
end
=begin
  There are two types of Custom Tags; ID and Label.
    *ID Tags are used in Card and Command declarations. Each ID Custom Tag
    equals an integer.
    *Label Tags are used in Menus, Descriptions, etc. These are just common
    names for things, as well as directories for graphics.
  A description of each Custom Tag and its use can be found in the Manual.
  
  When you see the Status CTs, you might notice the (slot #) at the end
of each description. This is to show where in the Array this data will stay.
I did this so you could understand that some States can't occur at the same time,
so they share a slot. If one state has the slot, an other state can't. If the slot
is given a new state, the first one will erase.
=end


Code:
module OS
  module TCG
    module LB
      Attack = "Fight!"
      Defend = "Block!"
      PosAtk = "Switch to Attack"
      PosDfn = "Switch to Defence"
      GetLib = "Card Library"
    end
  end
end


Code:
module OS
  module TCG
    # The Attack Method
    def attack(attacking, recieving)
      
    end
    # The Defend Method
    def defend(defending, attacking)
      
    end
    # The Activate Effect Method (by Tapping)
    def tap_activate(card_id)
      
    end
    # The AutoActivateEffect Method
    def auto_effect(card_id)
      
    end
  end
end

Code:
# Method : Attack
# at, Attacking Card
# df, Defending Card. Leave blank if attacking a duelist.
def attack(at, df = nil)
  @at = at
  if df == nil
    x = $duel.turn.id
    if $duel.turn.field.include(@at.owner_id)
      if x == 0
        @df = $duel.duelist[1]
      elsif x == 1
        @df = $duel.duelist[0]
      end
    else
      @df = x
    end
  else
    @df = df
  end
  s = spell_stop? #Checks if there are any spells that can prevent the attack.
  i = item_stop?  #Checks if there are any items that can prevent the attack.
  if s != nil
    @command_stop_atk.commands()
end
# $duel.turn.field_cards.include(@at.owner_id)
=begin
    $duel contains the Duel taking place. This means that $duel holds both
    Duelists, their Hands, Fields, Decks, Graves, Removed Cards, and Life.
    
    .turn is a method that returns the instance of the Duelist Object whose
    turn it is. For example, if it is dA's turn, .turn will return dA, not dB.
    
    .field returns the Duelist's field cards in an array.
    
    .owner_id retruns the variable, @owner_id of the Duelist/Card instances.
    The owner_id is given to the duelists cards to keep track of them,
    like in the Pokemon games!
=end

Code:
#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
#  This class performs menu screen processing.
#==============================================================================

class Scene_TCG
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     menu_index : command cursor's initial position
  #--------------------------------------------------------------------------
  def initialize(d1, d2, menu_index = 0)
    # Create the Main Duel Method!
    $duel = OS::TCG::Duel.new(d1, d2)
    @menu_index = menu_index
  end
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    $spriteset = Spriteset_Map.new
    $game_screen.start_tone_change(Tone.new(-255, -255, -255, 0), 0)
    #======================================================
    # Make main command window
    s1 = "Attack Phase"
    s2 = OS::TCG::LB::PosAtk
    s3 = OS::TCG::LB::PosDfn
    s4 = "End Turn"
    @main_command = Window_Command.new(160, [s1, s2, s3, s4])
    @main_command.index = @menu_index
    # Make the Attack/Block Window
    t1 = OS::TCG::LB::Attack
    t2 = OS::TCG::LB::Defend
    @battle_window = Window_Command.new(160, [t1, t2])
    @battle_window.active = false
    @battle_window.visible = false
    if $duel.turn.instance_of?(OS::TCG::Player)
      @battle_window.disable_item(1)
    else $duel.turn.instance_of?(OS::TCG::Duelist)
      @battle_window.disable_item(0)
    end
    # Setup Event Selector:
    @select = OS::TCG::Arrow_Event.new($game_map.map_id)
    # Create the Basic Windows:
    @d1_life = Life_Window.new(OS::TCG::StartLife)
    #======================================================
    $game_screen.start_tone_change(Tone.new(0, 0, 0, 0), 2)
    # Execute transition
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose the Spriteset
    $spriteset.dispose
    # Dispose of windows
    @main_command.dispose
    @battle_window.dispose
    @select = nil
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update the Spriteset
    $spriteset.update
    # Update windows
    @main_command.update
    @battle_window.update
    # Update the selector:
    @select.update_arrow
    # If command window is active: call update_command
    if @main_command.active
      update_main_command
      return
    end
    # Update the Battle Window!
    if @battle_window.active
      update_battle_win
      return
    end
    # Update the selector!
    if @select.active
      update_select_event
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when command window is active)
  #--------------------------------------------------------------------------
  def update_main_command
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Branch by command window cursor position
      case @main_command.index
      when 0
      when 1
      end
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when select event is active)
  #--------------------------------------------------------------------------
  def update_select_event
    # Press X or Esc
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      @select.active = false
      @select.visible = false
      @main_command.visible = true
      @main_command.active = true
      return
    end
    # Press SPACE or Enter
    if Input.trigger?(Input::C)
      @data_window.card_data($game_map.events[@select.index].card)
      @data_window.visible = true
      return
    end
    # Press Left or Up
    # Changes the index to the next highest Event ID
    if Input.trigger?(Input::LEFT) or Input.trigger?(Input::UP)
      for i in 1..$game_map.events.size
        if @select.index < i
          if @select.index == (i - 1)
            @select.index = i
          end
        end
      end
    end
    # Press Right or Down
    # Changes the index to the next lowest Event ID
    if Input.trigger?(Input::RIGHT) or Input.trigger?(Input::DOWN)
      for i in 1..$game_map.events.size
        if @select.index > i
          if @select.index == (i + 1)
            @select.index = i
          end
        end
      end
    end
  end
end

Code:
class Game_Event < Game_Character
  attr_reader :id
  attr_accessor :character_name
  attr_accessor :direction
  attr_accessor :pattern
  attr_accessor :opacity
  #====================#
  #Card Related Methods#
  #====================#
  def card=(card)
    @card = card
  end
  
  def card
    return @card
  end
  #============#
  #returns name#
  #============#
  def name
    return @event.name
  end
  #==========#
  #*return id#
  #==========#
  def id
    return @id
  end
end

module OS
  module TCG
    class Arrow_Event
      def initialize(map_id, index = 0)
        @index = index
        @active = false
        @visible = false
        events = []
        for i in 1..$game_map.events.size
          events.push($game_map.events[i].name)
        end
        setup_events(events)
        update_arrow
      end
      
      def setup_events(events)
        @mon_row = []
        @spl_row = []
        @itm_row = []
        for i in 1..events.size
          for m in 1..OS::TCG::FieldWidth
            if events[i] == "Mon#{m}"
              @mon_row.push(i) # Add the ID of the event to the row!
            elsif events[i] == "Spell#{m}"
              @spl_row.push(i)
            elsif events[i] == "Item#{m}"
              @itm_row.push(i)
            end
          end
        end
      end
      
      def index=(int)
        @index = int
        update_arrow
      end
      
      def index
        return @index
      end
      
      def active=(bool)
        @active = bool
        update_arrow
      end
      
      def active
        return @active
      end
      
      def visible=(bool)
        @active = bool
        update_arrow
      end
      
      def visible
        return @active
      end
    
      def update_arrow
        if @active
          if @visible
            for i in 0..@mon_row.size - 1
              if @index == @mon_row[i]
                if $dual.turn.field.include?(@index) && $duel.turn.field_index[@index].face_up
                  $game_map.events[@index].character_name = "Graphics/Characters/Cards.png"
                  $game_map.events[@index].direction = 2
                  $game_map.events[@index].pattern = 2
                  $game_map.events[@index].opacity = 255
                elsif $dual.turn.field.include?(@index) && !$duel.turn.field_index[@index].face_up
                  $game_map.events[@index].character_name = "Graphics/Characters/Cards.png"
                  $game_map.events[@index].direction = 4
                  $game_map.events[@index].pattern = 1
                  $game_map.events[@index].opacity = 255
                end
              end
            end
            for i in 0..@spl_row.size - 1
              if @index == @spl_row[i]
                if $dual.turn.field.include?(@index) && $duel.turn.field_index[@index].face_up
                  $game_map.events[@index].character_name = "Graphics/Characters/Cards.png"
                  $game_map.events[@index].direction = 2
                  $game_map.events[@index].pattern = 3
                  $game_map.events[@index].opacity = 255
                elsif $dual.turn.field.include?(@index) && !$duel.turn.field_index[@index].face_up
                  $game_map.events[@index].character_name = "Graphics/Characters/Cards.png"
                  $game_map.events[@index].direction = 4
                  $game_map.events[@index].pattern = 1
                  $game_map.events[@index].opacity = 255
                end
              end
            end
            for i in 0..@itm_row.size - 1
              if @index == @itm_row[i]
                if $dual.turn.field.include?(@index) && $duel.turn.field_index[@index].face_up
                  $game_map.events[@index].character_name = "Graphics/Characters/Cards.png"
                  $game_map.events[@index].direction = 4
                  $game_map.events[@index].pattern = 0
                  $game_map.events[@index].opacity = 255
                elsif $dual.turn.field.include?(@index) && !$duel.turn.field_index[@index].face_up
                  $game_map.events[@index].character_name = "Graphics/Characters/Cards.png"
                  $game_map.events[@index].direction = 4
                  $game_map.events[@index].pattern = 1
                  $game_map.events[@index].opacity = 255
                end
              end
            end
          end
        end
        correct_not_selected
        return
      end
      
      def correct_not_selected
        for i in 1..$game_map.events.size
          for m in 0..@mon_row.size - 1
            if i == @mon_row[m]
              if @index != @mon_row[m]
                $game_map.events[@index].character_name = "Graphics/Characters/Cards.png"
                $game_map.events[@index].direction = 4
                $game_map.events[@index].pattern = 2
                $game_map.events[@index].opacity = 255
              end
            end
          end
          for m in 0..@spl_row.size - 1
            if i == @spl_row[m]
              if @index != @spl_row[m]
                $game_map.events[@index].character_name = "Graphics/Characters/Cards.png"
                $game_map.events[@index].direction = 4
                $game_map.events[@index].pattern = 3
                $game_map.events[@index].opacity = 255
              end
            end
          end
          for m in 0..@itm_row.size - 1
            if i == @itm_row[m]
              if @index != @mon_row[m]
                $game_map.events[@index].character_name = "Graphics/Characters/Cards.png"
                $game_map.events[@index].direction = 6
                $game_map.events[@index].pattern = 0
                $game_map.events[@index].opacity = 255
              end
            end
          end
        end
        return
      end
    end
  end
end

Code:
module OS
  module TCG
    class Duel
      def initialize(duelist1, duelist2)
        @d1 = duelist1
        @d2 = duelist2
        if rand(3) >= 2
          @turn = @d1
        else
          @turn = @d2
        end
        shuffle_both # Shuffle Both Decks
      end
      
      def shuffle_both(what = 0)
        if what = 0
          @d1.deck = pre_shuffle(@d1.set_deck)
          @d2.deck = pre_shuffle(@d2.set_deck)
        elsif what = 1
          @d1.hand = pre_shuffle(@d1.hand)
          @d2.hand = pre_shuffle(@d2.hand)
        end
        return
      end
      
      def pre_shuffle(cards) # Thanks, Trickster!
        result = []
        until cards.empty?
          # Push a Random Card and Delete
          result << cards.delete_at(rand(cards.size))
        end
        return result
      end
      
      def turn
        return @turn
      end
      
      def field(duelist)
        return duelist.field
      end
      
      def hand(duelist)
        return duelist.hand
      end
      
      def owner_id(duelist)
        return duelist.owner_id
      end
    end
  end
end

Code:
module OS
  module TCG
    class Duelist
      attr_accessor :set_deck
      attr_accessor :deck
      def initialize(name, deck = [])
        @name = name
        @set_deck = deck
        @deck = []
        @owner_id = 0 # Assigned as variable $duelists is created!
        @field = {}
        @hand = {}
      end
      
      def owner_id=(int)
        @owner_id = int
      end
      
      def owner_id
        return @owner_id
      end
      
      def field_cards
        return @field
      end
      
      def field_index(card)
        return @field.index(card)
      end
      
      def field_at(event_id)
        return @field[event_id]
      end
      
      def hand
        return @hand
      end
      
      def draw_cards(amount = 1)
        c = []
        if !(@hand.size >= OS::TCG::MaxHand)
          if !(amount + @hand.size >= OS::TCG::MaxHand)
            for i in 0..amount - 1
              c.push(@deck.delete_at(0 + i))
            end
          end
        end
        for i in 0..c.size - 1
          @hand.push(c[i])
        end
        return c
      end
    end
  end
end

Code:
module OS
  module TCG
    class Player
      attr_accessor :set_deck
      attr_accessor :deck
      def initialize(name, lib = [], deck = [])
        @name = name
        @lib = lib
        @deck = [] # Holds the deck during duels.
        @set_deck = deck # The deck as it is set by the player/developer.
        @owner_id = 0 # Assigned as variable $duelists is created!
        @field = {} #Event ID => Card
        @hand = {} #Event ID => Card
        @life = OS::TCG::StartLife
        #reset
      end
      
      def cards_in_deck
        return @deck.size - 1
      end
      
      def name
        return @name
      end
      
      def life
        return @life
      end
      
      def owner_id=(int)
        @owner_id = int
      end
      
      def owner_id
        return @owner_id
      end
      
      def field_cards
        return @field
      end
      
      def field_index(card)
        return @field.index(card)
      end
      
      def field_at(event_id)
        return @field[event_id]
      end
      
      def hand
        return @hand
      end
      
      def draw_cards(amount = 1)
        c = []
        if !(@hand.size >= OS::TCG::MaxHand)
          if !(amount + @hand.size >= OS::TCG::MaxHand)
            for i in 0..amount - 1
              c.push(@deck.delete_at(0 + i))
            end
          end
        end
        for i in 0..c.size - 1
          @hand.push(c[i])
        end
        return c
      end
    end
    
    def reset
      @life = OS::TCG::StartLife
      @hand = {}
      @field = {}
    end
  end
end

I have not finished most of these, some are outside their classes, but one in particular (Arrow_Event) is in need of fixing for sure. It could be really handy to people making event-type systems that use a cursor (like some RM2K3 CMSs)

I guess this is my resignation from the project. I am taking a break for now on. No more major scripting projects until I know more about scripting. I will most likely start again when I begin making my next big project. It will be some time, I think, but when the time does come, I shall be much better. Good luck in your own endeavors, and Peace!
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top