Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Kyonides's Series of Demos
#18
Recently I've started developing this scriptlet that should allow me to begin a simple card game. So far it only displays few cards on screen. I haven't added any mechanics to be honest. Laughing Even so every card features an ID, a name and two stats, namely attack and defense. Nope, none of these are being displayed right now. Laughing + Tongue sticking out

The Scriptlet So Far

Code:
# * Karta XP - Alpha Stage
#   Scripter : Kyonides Arkanthes
#   2021-03-12

# * Script Calls * #

# $game_party.add_kard(Number)
# It won't add a card to your deck if:
# - Your deck reached the CARD_MAX limit
# - You've got CARD_TYPE_MAX cards of the same kind

# $game_party.enough_kards?
# $game_party.kards_max = Number
# $game_party.kards_max += Number
# $game_party.kards_max -= Number

module Karta
  BASE_CARD = 'card base.jpg'
  CARD_MIN = 3
  CARD_MAX = 20
  CARD_TYPE_MAX = 3
  NPC_CARD_X = [200, -200]
  NPC_CARD_Y = [40]
  PLAYER_CARD_X = [200, -200]
  PLAYER_CARD_Y = [320]
  CARD_NAMES = []
  CARD_FILENAMES = [BASE_CARD, BASE_CARD]
end

class Array
  def count(n)
    group = select{|m| m == n }
    group.size
  end
end

module RPG::Cache
  def self.kard(kid)
    self.load_bitmap('Graphics/Kards/' + Karta::CARD_FILENAMES[kid])
  end
end

class Kard
  attr_reader :id, :attack, :defense
  def initialize(cid=0)
    @id = cid
    @attack = 0
    @defense = 0
  end
  def <=>(other) other.id <=> @id end
  def name() Karta::CARD_NAMES[@id] || '?' end
end

class Game_Party
  alias :kyon_karta_gm_pty_init :initialize
  def initialize
    kyon_karta_gm_pty_init
    @kards = []
    @kards_max = 0
  end

  def add_kard(n)
    return nil if Karta::CARD_MAX + @kards_max == @kards.size
    temp_kard = Kard.new(n)
    return false if Karta::CARD_TYPE_MAX == @kards.count(temp_kard)
    @kards << temp_kard
  end
  def enough_kards?() Karta::CARD_MIN <= @kards.size end
  attr_reader :kards
  attr_accessor :kards_max
end

class KardSprite < RPG::Sprite
  def initialize(cid=nil)
    super(nil)
    return unless cid
    @id = cid
    self.bitmap = RPG::Cache.kard(Karta::BASE_CARD)
  end
end

class KartaScene
  include Karta
  def make_npc_cards
    @npc_card_data = [1,2,3]
    card_max = @npc_card_data.size
    card_max.times do |n|
      n = @npc_card_data[n]
      @npc_cards << card = KardSprite.new(n)
      card.x = NPC_CARD_X[0]
      card.y = NPC_CARD_Y[0]
    end
  end

  def make_player_cards
    @player_card_data = $game_party.kards.dup
    card_max = @player_card_data.size
    card_max.times do |n|
      n = @player_card_data[n]
      @player_cards << card = KardSprite.new(n)
      card.x = PLAYER_CARD_X[0]
      card.y = PLAYER_CARD_Y[0]
    end
  end
  
  def main
    @npc_cards = []
    @player_cards = []
    make_npc_cards
    make_player_cards
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      break if @exit
    end
    Graphics.freeze
    dispose
  end

  def dispose
    @player_cards.each{|c| c.dispose }
    @npc_cards.each{|c| c.dispose }
  end

  def update
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Map.new
      return @exit = true
    end
  end
end
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9

Maranatha!

The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.

[Image: SP1-Scripter.png]
[Image: SP1-Writer.png]
[Image: SP1-Poet.png]
[Image: SP1-PixelArtist.png]
[Image: SP1-Reporter.png]

My Original Stories (available in English and Spanish)

List of Compiled Binary Executables I have published...
HiddenChest & Roole

Give me a free copy of your completed game if you include at least 3 of my scripts! Laughing + Tongue sticking out

Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX
Reply
Thanks given by:


Messages In This Thread
Kyonides's Series of Demos - by kyonides - 07-27-2018, 08:57 AM
RE: KLevel XP Series of Demos - by kyonides - 07-30-2018, 04:58 AM
RE: KLevel XP Series of Demos - by kyonides - 07-31-2018, 12:40 AM
RE: KLevel XP Series of Demos - by DerVVulfman - 07-31-2018, 03:47 AM
RE: KLevel XP Series of Demos - by kyonides - 07-31-2018, 05:56 AM
RE: KLevel XP Series of Demos - by BeJeremiah - 07-31-2018, 08:41 AM
RE: KLevel XP Series of Demos - by kyonides - 07-31-2018, 01:50 PM
RE: KLevel XP Series of Demos - by kyonides - 08-01-2018, 03:00 PM
RE: KLevel XP Series of Demos - by kyonides - 08-02-2018, 04:30 AM
RE: KLevel XP Series of Demos - by DerVVulfman - 08-03-2018, 04:14 AM
RE: KLevel XP Series of Demos - by kyonides - 08-03-2018, 05:39 AM
RE: Kyonides's Series of Demos - by kyonides - 09-08-2018, 06:15 AM
RE: Kyonides's Series of Demos - by kyonides - 09-09-2018, 04:05 AM
RE: Kyonides's Series of Demos - by kyonides - 09-11-2018, 05:07 AM
RE: Kyonides's Series of Demos - by Melana - 09-11-2018, 04:13 PM
RE: Kyonides's Series of Demos - by DerVVulfman - 09-12-2018, 02:55 AM
RE: Kyonides's Series of Demos - by kyonides - 02-12-2019, 01:19 AM
RE: Kyonides's Series of Demos - by kyonides - 03-13-2021, 04:36 AM
RE: Kyonides's Series of Demos - by kyonides - 03-14-2021, 08:16 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Magin Series ZanderFrae 20 19,942 10-03-2012, 03:25 PM
Last Post: ZanderFrae



Users browsing this thread: