• Tidak ada hasil yang ditemukan

Rancang Bangun Game Wirausaha Muda Berbasis RPG Maker VX

N/A
N/A
Protected

Academic year: 2019

Membagikan "Rancang Bangun Game Wirausaha Muda Berbasis RPG Maker VX"

Copied!
26
0
0

Teks penuh

(1)

LAMPIRAN : LISTING PROGRAM

1. Modules

a. module Vocab

Modul ini mendefinisikan persyaratan dan pesan dari beberapa data sebagai konstan Variabel.

SaveMessage = "Simpan dislot mana?"

LoadMessage = "Lanjutkan game di slot mana?" File = "Data"

def self.save

return $data_system.terms.save end

def self.game_end

return $data_system.terms.game_end end

def self.new_game

(2)

def self.continue

return $data_system.terms.continue end

def self.shutdown

return $data_system.terms.shutdown end

end

b. module Sound

Modul ini memainkan efek suara. Diperoleh dengan efek suara yang ditentukan dalam Database dari $ data_system, dan memainkan mereka.

def self.play_cursor

$data_system.sounds[0].play end

def self.play_decision

$data_system.sounds[1].play end

def self.play_cancel

(3)

def self.play_buzzer

$data_system.sounds[3].play end

def self.play_save

$data_system.sounds[5].play end

def self.play_load

$data_system.sounds[6].play end

def self.play_shop

$data_system.sounds[17].play end

end

c. module Cache

Modul ini memuat masing-masing grafis, membuat objek Bitmap, dan mempertahankannya. Modul ini dibuat untuk mempercepat load dan menghemat memori.

def self.animation(filename, hue)

(4)

def self.character(filename)

load_bitmap("Graphics/Characters/", filename) end

def self.face(filename)

load_bitmap("Graphics/Faces/", filename) end

def self.parallax(filename)

load_bitmap("Graphics/Parallaxes/", filename) end

def self.picture(filename)

load_bitmap("Graphics/Pictures/", filename) end

def self.system(filename)

load_bitmap("Graphics/System/", filename) end

def self.clear

@cache = {} if @cache == nil @cache.clear

(5)

def self.load_bitmap(folder_name, filename, hue = 0) @cache = {} if @cache == nil

path = folder_name + filename

if not @cache.include?(path) or @cache[path].disposed? if filename.empty?

@cache[path] = Bitmap.new(32, 32) else

@cache[path] = Bitmap.new(path) end

end

if hue == 0

return @cache[path] else

key = [path, hue]

if not @cache.include?(key) or @cache[key].disposed? @cache[key] = @cache[path].clone

@cache[key].hue_change(hue) end

return @cache[key] end

(6)

2. Game Objects

a. class Game_Temp

Kelas ini menangani data sementara yang tidak termasuk dengan data simpan. Contoh kelas ini direferensikan oleh $ game_temp.

(7)

def initialize

@next_scene = nil @map_bgm = nil @map_bgs = nil

@common_event_id = 0 @in_battle = false @battle_proc = nil @shop_goods = nil

@shop_purchase_only = false @name_actor_id = 0

@name_max_char = 0 @menu_beep = false @last_file_index = 0 @debug_top_row = 0 @debug_index = 0

@background_bitmap = Bitmap.new(1, 1) end

(8)

b. class Game_Switches

Kelas ini menangani Switch yang disusun berdasarkan ‘Array’.

def initialize @data = [] end

def [](switch_id)

if @data[switch_id] == nil return false

else

return @data[switch_id] end

end

def []=(switch_id, value) if switch_id <= 5000 @data[switch_id] = value end

(9)

c. class Game_Variables

Kelas ini menangani variable yang disusun berdasarkan ‘Array’.

def initialize @data = [] end

def [](variable_id)

if @data[variable_id] == nil return 0

else

return @data[variable_id] end

end

def []=(variable_id, value) if variable_id <= 5000 @data[variable_id] = value end

(10)

3. Sprites

a. class Sprite_Base

Kelas untuk menambahkan animasi sprite. class Sprite_Base < Sprite

@@animations = []

@@_reference_count = {} def initialize(viewport = nil) super(viewport)

@use_sprite = true @animation_duration = 0 end

def dispose super

dispose_animation end

def update super

if @animation != nil

@animation_duration -= 1

if @animation_duration % 4 == 0 update_animation

end end

(11)

def animation?

return @animation != nil end

def start_animation(animation, mirror = false) dispose_animation

@animation = animation return if @animation == nil @animation_mirror = mirror

@animation_duration = @animation.frame_max * 4 + 1 load_animation_bitmap

@animation_sprites = []

if @animation.position != 3 or not @@animations.include?(animation) if @use_sprite

for i in 0..15

sprite = ::Sprite.new(viewport) sprite.visible = false

@animation_sprites.push(sprite) end

unless @@animations.include?(animation) @@animations.push(animation)

end end end

(12)

@animation_ox = 544 / 2 @animation_oy = 416 / 2 else

@animation_ox = viewport.rect.width / 2 @animation_oy = viewport.rect.height / 2 end

else

@animation_ox = x - ox + width / 2 @animation_oy = y - oy + height / 2 if @animation.position == 0

@animation_oy -= height / 2 elsif @animation.position == 2 @animation_oy += height / 2 end

end end

def load_animation_bitmap

animation1_name = @animation.animation1_name animation1_hue = @animation.animation1_hue animation2_name = @animation.animation2_name animation2_hue = @animation.animation2_hue

@animation_bitmap1 = Cache.animation(animation1_name, animation1_hue)

(13)

if @@_reference_count.include?(@animation_bitmap1) @@_reference_count[@animation_bitmap1] += 1 else

@@_reference_count[@animation_bitmap1] = 1 end

if @@_reference_count.include?(@animation_bitmap2) @@_reference_count[@animation_bitmap2] += 1 else

@@_reference_count[@animation_bitmap2] = 1 end

Graphics.frame_reset end

def dispose_animation

if @animation_bitmap1 != nil

@@_reference_count[@animation_bitmap1] -= 1 if @@_reference_count[@animation_bitmap1] == 0 @animation_bitmap1.dispose

end end

if @animation_bitmap2 != nil

@@_reference_count[@animation_bitmap2] -= 1 if @@_reference_count[@animation_bitmap2] == 0 @animation_bitmap2.dispose

(14)

if @animation_sprites != nil for sprite in @animation_sprites sprite.dispose

end

@animation_sprites = nil @animation = nil

end

@animation_bitmap1 = nil @animation_bitmap2 = nil end

def update_animation if @animation_duration > 0

frame_index = @animation.frame_max - (@animation_duration + 3) / 4 animation_set_sprites(@animation.frames[frame_index])

for timing in @animation.timings if timing.frame == frame_index animation_process_timing(timing) end

end else

dispose_animation end

end

(15)

for i in 0..15

sprite = @animation_sprites[i] next if sprite == nil

pattern = cell_data[i, 0]

if pattern == nil or pattern == -1 sprite.visible = false

next end

if pattern < 100

sprite.bitmap = @animation_bitmap1 else

sprite.bitmap = @animation_bitmap2 end

sprite.visible = true

sprite.src_rect.set(pattern % 5 * 192, pattern % 100 / 5 * 192, 192, 192) if @animation_mirror

sprite.x = @animation_ox - cell_data[i, 1] sprite.y = @animation_oy + cell_data[i, 2] sprite.angle = (360 - cell_data[i, 4])

sprite.mirror = (cell_data[i, 5] == 0) else

(16)

sprite.mirror = (cell_data[i, 5] == 1) end

sprite.z = self.z + 300 + i sprite.ox = 96

sprite.oy = 96

sprite.zoom_x = cell_data[i, 3] / 100.0 sprite.zoom_y = cell_data[i, 3] / 100.0

sprite.opacity = cell_data[i, 6] * self.opacity / 255.0 sprite.blend_type = cell_data[i, 7]

end end

def animation_process_timing(timing) timing.se.play

case timing.flash_scope when 1

self.flash(timing.flash_color, timing.flash_duration * 4) when 2

if viewport != nil

viewport.flash(timing.flash_color, timing.flash_duration * 4) end

when 3

self.flash(nil, timing.flash_duration * 4) end

(17)

b. class Sprite_Character

kelas yang berfungsi untuk menampilkan sprite character dan secara otomatis mengubah kondisinya sesuai dengan event yang terjadi.

class Sprite_Character < Sprite_Base attr_accessor :character

def initialize(viewport, character = nil) super(viewport)

@character = character @balloon_duration = 0 update

end

def dispose dispose_balloon super

end

def update super

update_bitmap

self.visible = (not @character.transparent) update_src_rect

(18)

self.y = @character.screen_y self.z = @character.screen_z self.opacity = @character.opacity

self.blend_type = @character.blend_type self.bush_depth = @character.bush_depth update_balloon

if @character.animation_id != 0

animation = $data_animations[@character.animation_id] start_animation(animation)

@character.animation_id = 0 end

if @character.balloon_id != 0

@balloon_id = @character.balloon_id start_balloon

@character.balloon_id = 0 end

end

def tileset_bitmap(tile_id) set_number = tile_id / 256

(19)

end

def update_bitmap

if @tile_id != @character.tile_id or

@character_name != @character.character_name or @character_index != @character.character_index @tile_id = @character.tile_id

@character_name = @character.character_name @character_index = @character.character_index if @tile_id > 0

sx = (@tile_id / 128 % 2 * 8 + @tile_id % 8) * 32; sy = @tile_id % 256 / 8 % 16 * 32;

self.bitmap = tileset_bitmap(@tile_id) self.src_rect.set(sx, sy, 32, 32)

self.ox = 16 self.oy = 32 else

self.bitmap = Cache.character(@character_name) sign = @character_name[/^[\!\$]./]

if sign != nil and sign.include?('$') @cw = bitmap.width / 3

@ch = bitmap.height / 4 else

(20)

end

self.ox = @cw / 2 self.oy = @ch end

end end

def update_src_rect if @tile_id == 0

index = @character.character_index

pattern = @character.pattern < 3 ? @character.pattern : 1 sx = (index % 4 * 3 + pattern) * @cw

sy = (index / 4 * 4 + (@character.direction - 2) / 2) * @ch self.src_rect.set(sx, sy, @cw, @ch)

end end

def start_balloon dispose_balloon

@balloon_duration = 8 * 8 + BALLOON_WAIT @balloon_sprite = ::Sprite.new(viewport)

@balloon_sprite.bitmap = Cache.system("Balloon") @balloon_sprite.ox = 16

@balloon_sprite.oy = 32 update_balloon

end

(21)

if @balloon_duration > 0 @balloon_duration -= 1 if @balloon_duration == 0 dispose_balloon

else

@balloon_sprite.x = x

@balloon_sprite.y = y - height @balloon_sprite.z = z + 200

if @balloon_duration < BALLOON_WAIT sx = 7 * 32

else

sx = (7 - (@balloon_duration - BALLOON_WAIT) / 8) * 32 end

sy = (@balloon_id - 1) * 32

@balloon_sprite.src_rect.set(sx, sy, 32, 32) end

end end

def dispose_balloon if @balloon_sprite != nil @balloon_sprite.dispose @balloon_sprite = nil end

(22)

4. Module tambahan

a. HUD Energi

Module ini membuat tampilan energi yang digunakan sebagai tolak ukur masa aktif pemain per hari.

module Gauge

VARIABLE_ID = 20 VISIBLE_SWITCH = 20 X = 0

Y = 0

GAUGE_WIDTH = 120 GAUGE_HEIGHT = 6 GAUGE_MAX = 100

COLOUR1 = Color.new( 0, 255, 100) COLOUR2 = Color.new( 0, 255, 0) SHOW_WINDOW = true

TEXT ="Energi" end

class Window_GaugeDisplay < Window_Base include Gauge

def initialize

super(X, Y, GAUGE_WIDTH + 16, GAUGE_HEIGHT + WLH + 32) self.visible = $game_switches[VISIBLE_SWITCH]

(23)

self.contents.draw_text(-8, -7, self.contents.width, WLH, TEXT, 1) refresh

end def refresh

gw = GAUGE_WIDTH * $game_variables[VARIABLE_ID] / GAUGE_MAX

gc1 = COLOUR1 gc2 = COLOUR2

self.contents.fill_rect(0, 0 + WLH - 8, GAUGE_WIDTH, GAUGE_HEIGHT, gauge_back_color)

self.contents.gradient_fill_rect(0, 0 + WLH - 8, gw, GAUGE_HEIGHT, gc1, gc2)

end def update

self.visible = $game_switches[VISIBLE_SWITCH] var = $game_variables[VARIABLE_ID]

refresh if var != @old_var @old_var = var

end end

class Scene_Map

(24)

def start

var_guage_old_start

@var_guage = Window_GaugeDisplay.new end

def update

var_guage_old_update @var_guage.update end

def terminate

var_guage_old_terminate @var_guage.dispose end

end

b. module Gold_Map

modul yang memunculkan jumlah uang di interface.

(25)

class Window_Gold_map < Window_Base def initialize

super(0, 0, 135, 85) self.opacity = 0 refresh

end

def refresh

self.contents.clear

cx = contents.text_size($data_system.terms.gold).width self.contents.font.color = normal_color

self.contents.draw_text(-20, 30, 120, 32, $game_party.gold.to_s, 2) self.contents.font.color = system_color

self.contents.draw_text(100-cx, -3, cx, 32, $data_system.terms.gold, 2) end

def update refresh end end

class Scene_Map include Gold_Map

alias falcao_gold_main main def main

(26)

@gold_map.y = Posision_Y

if $game_switches[Gold_disable] == false @gold_map.visible = true

else

@gold_map.visible = false end

falcao_gold_main @gold_map.dispose end

alias falcao_gold_update update def update

@gold_map.update

if $game_switches[Gold_disable] == false @gold_map.visible = true

else

@gold_map.visible = false end

falcao_gold_update end

Referensi

Dokumen terkait

Oleh karena itu, peneliti berharap dengan adanya pengembangan alat ukur coping stress ini, para remaja, khususnya pelajar SMA dapat mengidentifikasi stres yang dialaminya dan

Hal ini berarti jika individu mempunyai intensitas mengikuti pengajian kitab al-Hikam yang tinggi maka individu akan termotivasi untuk mengikuti pengajian tersebut

1) Pada model Path Analysis, hubungan antar variabel adalah bersifat linier, adaptif, dan bersifat normal. 2) Hanya sistem aliran kausal ke satu arah artinya tidak ada

Sejak 85 tahun sejarah penubuhan Universiti Putra Malaysia bermula sebagai Sekolah Pertanian Malaya pada tahun 1931, tahun 2016 mencatatkan banyak kejayaan pada peringkat

Hal seperti inilah yang merupakan ungkapan nyata pada saat ini, penulis tuangkan dalam lukisan dengan menggunakan subject matter katak hijau, guna mengekspresikan

Dari data hasil analisis maka penilaian kebutuhan penduduk usia sekolah tingat SLTP di kabupaten Tambrauw tahun 2014 adalah Kecamatan Fef cukup, Kecamatan Syujak

Penelitian ini adalah penelitian kualitatif yang bersifat deskriptif dan ditunjang dengan penelitian kuantitatif, dengan rancangan penelitian cross sectional dan menggunakan

Perpustakaan merupakan lembaga layanan jasa yang bersifat sosio ekonomi (non profit ) , namun mengingat implementasi dan pengembangan sistem teknologi informasi memerlukan biaya