hart Senior
Posts : 805 Thanked : 38 Engine : Other Skill : Very Beginner Type : Developer
| Subyek: [RGSS2]Minigame Tembak2 2010-11-06, 12:33 | |
| Tembak2 Versi: 1.0 Tipe: Minigame PengenalanSeri kedua dari seri script RGSS2 gaje ku. Saya tau ini kurang berguna karena ada script milik orang lain(kalau ga salah tomoaky ya namanya), yang bisa bikin danmaku, jauh lebih bagus, konfigurasi jauh lebih baik, dll. Tapi karena udah terlanjur dibuat ya sudah lah Fitur
- Bisa dipanggil via event.
Cara menggunakan script
- Seperti biasa, copy paste di script editor di atas main
- Panggil melalui event via event script, caranya liat di scriptnya.
- Bila anda tidak mendonlod demonya, anda perlu memasukkan beberapa gambar dan menamainya sesuai dengan yang di bagian script(atau di bagian scriptnya yg namanya diubah juga bisa).
Screenshotsbesok. Demohttp://www.mediafire.com/?2b64deku1imj0mi Scriptsdianjurkan untuk mendonlod demonya, tapi kalau mau ya.. - Code:
-
#=============================================================================== # * Cara Menggunakan Script #------------------------------------------------------------------------------- # Panggil script dari event dengan cara memilih tab advanced, script, kemudian # masukkan kode berikut: # # $scene = Scene_Tembak2.new(custom, bulletspeed, movespeed, spawntime, limit, onscore) # ket: # - custom = dapat diisi dengan nilai true atau false. Bila diisi dengan true, # game akan berjalan standard, dan argumen lain tidak perlu lagi diisi # - bulletspeed = kecepatan peluru. Isi dengan angka # - movespeed = kecepatan gerak. Isi dengan angka # - spawntime = waktu untuk memunculkan musuh baru. Semakin sedikit nilainya semakin cepat musuh muncul # - limit = target score atau waktu(dalam frame) # - onscore = diisi dengan nilai true atau false. Bila true, maka bila score mencapai nilai limit, anda menang # bila false, maka bila nilai waktu mencapai nilai limit, anda menang # # Script ini sangat kaku, artinya konfigurasi nya sangat sedikit dan terbatas >.< # Konfigurasi dapat dilakukan dengan mengubah nilai2 konstanta2 di bawah ini #=============================================================================== module Hart module Tembak2 #=============================================================================== # * Gameplay related configuration #=============================================================================== PLAYER_STARTING_MOVESPEED = 3 BULLET_STARTING_MOVESPEED = 4 ENEMY_MOVESPEED = [1, 1, 1, 1] ENEMY_SCORE = [100, 150, 200, 250] SCORE_VARIABLE_ID = 1 HIGHSCORE_VARIABLE_ID = 2 CUSTOM_MODE_RESULT_VARIABLE_ID = 3 SHOOT_DELAY = 30 ENEMY_SHOOT_DELAY = [100, 100, 80, 0] PLAYER_COLLISION_TOLERANCE = 0 STARTING_SPAWN_TIME = 360 LEVEL_SCORE_INTERVAL = 1000 SPAWN_TIME_INTERVAL = 40 MOVESPEED_INTERVAL = 2 BULLETSPEED_INTERVAL = 2 #=============================================================================== # * Graphics related configuration #=============================================================================== GRAPHICS_PATH = "Graphics/Pictures/" PLAYER_IMAGE = "player.png" ENEMY_IMAGE = ["enemy1.png", "enemy2.png", "enemy3.png", "enemy4.png"] PLAYER_BULLET_IMAGE = "playerbullet.png" ENEMY_BULLET_IMAGE = "enemybullet1.png" EXPLOSION_IMAGE = "explosion.png" BACKGROUND_IMAGE = "background.png" OBJECT1_IMAGE = "island1.png" OBJECT2_IMAGE = "island2.png" OBJECT3_IMAGE = "island3.png"
PLAYER_IMAGE_FRAMES = 3 ENEMY_IMAGE_FRAMES = 3 EXPLOSION_IMAGE_FRAMES = 6 BULLET_IMAGE_SIZE = 8 BACKGROUND_SCROLLING_SPEED = 2 #=============================================================================== # * SE related configuration #=============================================================================== SE_PATH = "Audio/SE/" EXPLOSION_SOUND = "explosion.wav" #=============================================================================== end end
class Tembak2_Object attr_accessor :x attr_accessor :y attr_accessor :end attr_accessor :sprite def initialize @x = -100 @y = -100 @end = false @sprite = Sprite.new @sprite.x = @x @sprite.y = @y end def update @sprite.x = @x @sprite.y = @y end def dispose @sprite.dispose end end
class Tembak2_Bullet < Tembak2_Object attr_accessor :speed attr_accessor :type attr_accessor :angle def initialize(x, y, speed, type, angle = 0) super() @x = x @y = y @speed = speed @type = type @angle = angle @sprite.z = 10 if @type == 0 @sprite.bitmap = Cache.load_bitmap(Hart::Tembak2::GRAPHICS_PATH, Hart::Tembak2::PLAYER_BULLET_IMAGE) else @sprite.bitmap = Cache.load_bitmap(Hart::Tembak2::GRAPHICS_PATH, Hart::Tembak2::ENEMY_BULLET_IMAGE) end end def update super if @type == 0 @y -= @speed else @y += @speed * Math.cos(@angle * 180 / 3.14) @x += @speed * Math.sin(@angle * 180 / 3.14) end @end = true if @y < 0 - @sprite.bitmap.height || @y > Graphics.height + @sprite.bitmap.height end def dispose super end end
class Tembak2_Player < Tembak2_Object attr_accessor :speed attr_accessor :bulletcount attr_accessor :bulletspeed def initialize super @x = 240 @y = 300 @speed = Hart::Tembak2::PLAYER_STARTING_MOVESPEED @sprite.z = 100 @frame = 0 @frame_delay = 0 #@bulletspeed = Hart::Tembak2::BULLET_STARTING_MOVESPEED @bulletcount = Hart::Tembak2::SHOOT_DELAY @bullets = [] temp = Cache.load_bitmap(Hart::Tembak2::GRAPHICS_PATH, Hart::Tembak2::PLAYER_IMAGE) frame_width = temp.width / Hart::Tembak2::PLAYER_IMAGE_FRAMES frame_height = temp.height @sprite.bitmap = Bitmap.new(frame_width, frame_height) end def update super @frame_delay += 1 @bulletcount -= 1 if @frame_delay >= 5 @frame_delay = 0 @frame = (@frame + 1) % Hart::Tembak2::PLAYER_IMAGE_FRAMES temp = Cache.load_bitmap(Hart::Tembak2::GRAPHICS_PATH, Hart::Tembak2::PLAYER_IMAGE) frame_width = temp.width / Hart::Tembak2::PLAYER_IMAGE_FRAMES frame_height = temp.height rect = Rect.new(@frame * frame_width, 0, frame_width, frame_height) @sprite.bitmap.blt(0, 0, temp, rect) end end def dispose super end end
class Tembak2_Enemy < Tembak2_Object attr_accessor :type attr_accessor :speed attr_accessor :bulletcount attr_accessor :bulletspeed def initialize(x, y, type) super() @x = x @y = y @type = type @speed = Hart::Tembak2::ENEMY_MOVESPEED[type] @sprite.z = 99 @frame = 0 @frame_delay = 0 #@bulletspeed = Hart::Tembak2::BULLET_STARTING_MOVESPEED @bulletcount = Hart::Tembak2::ENEMY_SHOOT_DELAY[@type] @bullets = [] temp = Cache.load_bitmap(Hart::Tembak2::GRAPHICS_PATH, Hart::Tembak2::ENEMY_IMAGE[@type]) frame_width = temp.width / Hart::Tembak2::ENEMY_IMAGE_FRAMES frame_height = temp.height @sprite.bitmap = Bitmap.new(frame_width, frame_height) end def update super @frame_delay += 1 @bulletcount -= 1 if @frame_delay >= 5 @frame_delay = 0 @frame = (@frame + 1) % Hart::Tembak2::ENEMY_IMAGE_FRAMES temp = Cache.load_bitmap(Hart::Tembak2::GRAPHICS_PATH, Hart::Tembak2::ENEMY_IMAGE[@type]) frame_width = temp.width / Hart::Tembak2::ENEMY_IMAGE_FRAMES frame_height = temp.height rect = Rect.new(@frame * frame_width, 0, frame_width, frame_height) @sprite.bitmap.blt(0, 0, temp, rect) end if @type == 3 @y -= @speed else @y += @speed end if @type == 3 @end = true if @y < -@sprite.bitmap.height else @end = true if @y > Graphics.height + @sprite.bitmap.height end end def dispose super end end
class Tembak2_Background def initialize @sprite1 = Sprite.new @sprite1.bitmap = Cache.load_bitmap(Hart::Tembak2::GRAPHICS_PATH, Hart::Tembak2::BACKGROUND_IMAGE) @sprite1.z = 0 @sprite1.x = 0 @sprite1.y = 0 @sprite2 = Sprite.new @sprite2.bitmap = Cache.load_bitmap(Hart::Tembak2::GRAPHICS_PATH, Hart::Tembak2::BACKGROUND_IMAGE) @sprite1.z = 0 @sprite1.x = 0 @sprite1.y = 0 - Graphics.height @scroll_speed = Hart::Tembak2::BACKGROUND_SCROLLING_SPEED @sprite_obj1 = Sprite.new @sprite_obj1.bitmap = Cache.load_bitmap(Hart::Tembak2::GRAPHICS_PATH, Hart::Tembak2::OBJECT1_IMAGE) @sprite_obj1.x = rand(Graphics.width - @sprite_obj1.bitmap.width) @sprite_obj1.y = 30 @sprite_obj1.z = 1 @sprite_obj2 = Sprite.new @sprite_obj2.bitmap = Cache.load_bitmap(Hart::Tembak2::GRAPHICS_PATH, Hart::Tembak2::OBJECT2_IMAGE) @sprite_obj2.x = rand(Graphics.width - @sprite_obj2.bitmap.width) @sprite_obj2.y = 185 @sprite_obj2.z = 1 @sprite_obj3 = Sprite.new @sprite_obj3.bitmap = Cache.load_bitmap(Hart::Tembak2::GRAPHICS_PATH, Hart::Tembak2::OBJECT3_IMAGE) @sprite_obj3.x = rand(Graphics.width - @sprite_obj3.bitmap.width) @sprite_obj3.y = 320 @sprite_obj3.z = 1 end def update @sprite1.y += @scroll_speed @sprite2.y += @scroll_speed if @sprite1.y >= Graphics.height || @sprite2.y >= 0 @sprite1.y = 0 @sprite2.y = -Graphics.height end @sprite_obj1.y += @scroll_speed if @sprite_obj1.y >= Graphics.height @sprite_obj1.y = -65 @sprite_obj1.x = rand(Graphics.width - @sprite_obj1.bitmap.width) end @sprite_obj2.y += @scroll_speed if @sprite_obj2.y >= Graphics.height @sprite_obj2.y = -65 @sprite_obj2.x = rand(Graphics.width - @sprite_obj2.bitmap.width) end @sprite_obj3.y += @scroll_speed if @sprite_obj3.y >= Graphics.height @sprite_obj3.y = -65 @sprite_obj3.x = rand(Graphics.width - @sprite_obj3.bitmap.width) end end def dispose @sprite1.dispose @sprite2.dispose @sprite_obj1.dispose @sprite_obj2.dispose @sprite_obj3.dispose end end
class Tembak2_Explosion attr_accessor :end def initialize(x, y) @sprite = Sprite.new temp = Cache.load_bitmap(Hart::Tembak2::GRAPHICS_PATH, Hart::Tembak2::EXPLOSION_IMAGE) frame_width = temp.width / Hart::Tembak2::EXPLOSION_IMAGE_FRAMES frame_height = temp.height @sprite.bitmap = Bitmap.new(frame_width, frame_height) @sprite.z = 120 @sprite.x = x @sprite.y = y @frame_delay = 0 @frame = 0 @end = false end def update @frame_delay += 1 if @frame_delay >= 5 @frame_delay = 0 @frame += 1 temp = Cache.load_bitmap(Hart::Tembak2::GRAPHICS_PATH, Hart::Tembak2::EXPLOSION_IMAGE) frame_width = temp.width / Hart::Tembak2::EXPLOSION_IMAGE_FRAMES frame_height = temp.height rect = Rect.new(@frame * frame_width, 0, frame_width, frame_height) @sprite.bitmap.blt(0, 0, temp, rect) end @end = true if @frame >= 5 end def dispose @sprite.dispose end end
class Scene_Tembak2 < Scene_Base def initialize(custom = false, bullet_speed = 0, spawn_time = 0, movespeed = 0, limit = 0, on_score = false) @player = Tembak2_Player.new @enemies = [] @bullets = [] @explosions = [] @background = Tembak2_Background.new @score = 0 @spawn_count = 0 @custom = custom if custom @bullet_speed = bullet_speed @spawn_time = spawn_time @limit = limit @on_score = on_score @player.speed = movespeed @time = 0 else @bullet_speed = Hart::Tembak2::BULLET_STARTING_MOVESPEED @spawn_time = Hart::Tembak2::STARTING_SPAWN_TIME @level = 0 end end def start super @spr_score = Sprite.new @spr_score.bitmap = Bitmap.new(Graphics.width, 32) @spr_score.bitmap.clear @spr_score.x = 0 @spr_score.y = Graphics.height / 2 @spr_score.z = 150 end def terminate super @player.dispose @background.dispose @spr_score.dispose for enemy in @enemies next if enemy == nil enemy.dispose end for bullet in @bullets next if bullet == nil bullet.dispose end for explosion in @explosions next if explosion == nil explosion.dispose end end def update super @background.update @player.update @spr_score.bitmap.clear @spr_score.bitmap.draw_text(0, 0, Graphics.width, 32, "Score: " + @score.to_s) spawn_enemy update_level for enemy in @enemies next if enemy == nil if enemy.bulletcount <= 0 enemy.bulletcount = Hart::Tembak2::ENEMY_SHOOT_DELAY[enemy.type] if enemy.type == 0 @bullets.push(Tembak2_Bullet.new(enemy.x + enemy.sprite.bitmap.width / 2 - Hart::Tembak2::BULLET_IMAGE_SIZE, enemy.y + enemy.sprite.bitmap.height - Hart::Tembak2::BULLET_IMAGE_SIZE, @bullet_speed, (enemy.type + 1), rand(360))) elsif enemy.type == 1 @bullets.push(Tembak2_Bullet.new(enemy.x + enemy.sprite.bitmap.width / 2 - Hart::Tembak2::BULLET_IMAGE_SIZE, enemy.y + enemy.sprite.bitmap.height - Hart::Tembak2::BULLET_IMAGE_SIZE, @bullet_speed, (enemy.type + 1), 210)) @bullets.push(Tembak2_Bullet.new(enemy.x + enemy.sprite.bitmap.width / 2 - Hart::Tembak2::BULLET_IMAGE_SIZE, enemy.y + enemy.sprite.bitmap.height - Hart::Tembak2::BULLET_IMAGE_SIZE, @bullet_speed, (enemy.type + 1), -210)) elsif enemy.type == 2 @bullets.push(Tembak2_Bullet.new(enemy.x + enemy.sprite.bitmap.width / 2 - Hart::Tembak2::BULLET_IMAGE_SIZE, enemy.y + enemy.sprite.bitmap.height - Hart::Tembak2::BULLET_IMAGE_SIZE, @bullet_speed, (enemy.type + 1))) end end enemy.update if !enemy.end enemy.dispose if enemy.end enemy = nil if enemy.end end for bullet in @bullets next if bullet == nil bullet.update if !bullet.end bullet.dispose if bullet.end bullet = nil if bullet.end end for explosion in @explosions next if explosion == nil explosion.update if !explosion.end explosion.dispose if explosion.end explosion = nil if explosion.end end update_input check_collision tembak2_end if @player.end end def check_collision for bullet in @bullets next if bullet == nil || bullet.end for enemy in @enemies next if enemy == nil || enemy.end if bullet.type == 0 && collide?(bullet, enemy) Audio.se_play(Hart::Tembak2::SE_PATH + Hart::Tembak2::EXPLOSION_SOUND) @explosions.push(Tembak2_Explosion.new(enemy.x, enemy.y)) @score += Hart::Tembak2::ENEMY_SCORE[enemy.type] enemy.end = true enemy.dispose bullet.end = true bullet.dispose end end end for enemy in @enemies next if enemy == nil || enemy.end if collide?(@player, enemy, true) Audio.se_play(Hart::Tembak2::SE_PATH + Hart::Tembak2::EXPLOSION_SOUND) @player.end = true @player.sprite.visible = false end end for bullet in @bullets next if bullet == nil || bullet.end if bullet.type > 0 && collide?(bullet, @player, true) Audio.se_play(Hart::Tembak2::SE_PATH + Hart::Tembak2::EXPLOSION_SOUND) @player.end = true @player.sprite.visible = false end end end def collide?(obj1, obj2, player = false) if player return obj1.x > obj2.x - obj1.sprite.bitmap.width + Hart::Tembak2::PLAYER_COLLISION_TOLERANCE && obj1.x < obj2.x + obj2.sprite.bitmap.width - Hart::Tembak2::PLAYER_COLLISION_TOLERANCE && obj1.y > obj2.y - obj1.sprite.bitmap.height + Hart::Tembak2::PLAYER_COLLISION_TOLERANCE && obj1.y < obj2.y + obj1.sprite.bitmap.height - Hart::Tembak2::PLAYER_COLLISION_TOLERANCE else return obj1.x > obj2.x - obj1.sprite.bitmap.width && obj1.x < obj2.x + obj2.sprite.bitmap.width && obj1.y > obj2.y - obj1.sprite.bitmap.height && obj1.y < obj2.y + obj1.sprite.bitmap.height end end def update_input if Input.press?(Input::RIGHT) @player.x += @player.speed if @player.x < Graphics.width - @player.sprite.bitmap.width end if Input.press?(Input::LEFT) @player.x -= @player.speed if @player.x > 0 end if Input.press?(Input::UP) @player.y -= @player.speed if @player.y > 0 end if Input.press?(Input::DOWN) @player.y += @player.speed if @player.y < Graphics.height - @player.sprite.bitmap.height end if Input.press?(Input::X) if @player.bulletcount <= 0 @player.bulletcount = Hart::Tembak2::SHOOT_DELAY @bullets.push(Tembak2_Bullet.new(@player.x + @player.sprite.bitmap.width / 2 - 16, @player.y, @bullet_speed, 0)) end end end def spawn_enemy @spawn_count += 1 if @spawn_count >= @spawn_time @spawn_count = 0 type = rand(4) if type == 3 y = Graphics.height + 65 else y = -65 end x = rand(Graphics.width - 32) @enemies.push(Tembak2_Enemy.new(x, y, type)) end end def update_level if @custom if @on_score if @score >= @limit @player.end = true $game_variables[Hart::Tembak2::CUSTOM_MODE_RESULT_VARIABLE_ID] = 1 end else @time += 1 if @time >= @limit @player.end = true $game_variables[Hart::Tembak2::CUSTOM_MODE_RESULT_VARIABLE_ID] = 1 end end else if @score >= 8 * Hart::Tembak2::LEVEL_SCORE_INTERVAL @level = 8 elsif @score >= 7 * Hart::Tembak2::LEVEL_SCORE_INTERVAL @level = 7 elsif @score >= 6 * Hart::Tembak2::LEVEL_SCORE_INTERVAL @level = 6 elsif @score >= 5 * Hart::Tembak2::LEVEL_SCORE_INTERVAL @level = 5 elsif @score >= 4 * Hart::Tembak2::LEVEL_SCORE_INTERVAL @level = 4 elsif @score >= 3 * Hart::Tembak2::LEVEL_SCORE_INTERVAL @level = 3 elsif @score >= 2 * Hart::Tembak2::LEVEL_SCORE_INTERVAL @level = 2 elsif @score >= Hart::Tembak2::LEVEL_SCORE_INTERVAL @level = 1 end @bullet_speed = Hart::Tembak2::BULLET_STARTING_MOVESPEED + @level * Hart::Tembak2::BULLETSPEED_INTERVAL @player.speed = Hart::Tembak2::PLAYER_STARTING_MOVESPEED + @level * Hart::Tembak2::MOVESPEED_INTERVAL @spawn_time = Hart::Tembak2::STARTING_SPAWN_TIME + @level * Hart::Tembak2::SPAWN_TIME_INTERVAL @spawn_time = 5 if @spawn_time < 5 end end def tembak2_end Graphics.wait(60) $game_variables[1] = @score $game_variables[2] = @score if @score > $game_variables[2] $scene = Scene_Map.new end end
Credits
- Hart, bila mau. Kalau ga mau gpp.
- GM, bila kamu menggunakan resource2nya.
FAQQ: Konfigurasinya ga flexibel(sangat terbatas). A: biarin Q: aku nemu bug! A: Lapor ke sini atau ke kantor polisi.
| |
|
Yaden Legendary
Posts : 2056 Thanked : 17 Engine : RMVX Skill : Very Beginner Type : Artist
| Subyek: Re: [RGSS2]Minigame Tembak2 2010-11-06, 12:46 | |
| wah.. katanya ga scripting lagi dd?? tapi ini keren~!! script buat minigame.. aku coba dulu ya.. | |
|
Rei_Fan49 Ex-Scripter
Posts : 304 Thanked : 15 Engine : Multi-Engine User Skill : Advanced Type : Scripter
| Subyek: Re: [RGSS2]Minigame Tembak2 2010-11-06, 12:49 | |
| - yaden_chandra wrote:
- wah.. katanya ga scripting lagi dd??
tapi ini keren~!! script buat minigame.. aku coba dulu ya.. ya commentnya nanti aja... si hart kayanya pengen scripting kalo mau ( ) oh iya.. hart, ane liat ini scriptnya sedikit panjang.. (gara2 variable おたい!) saran ane diperpendek nama variablenya... kaya disingkat-singkat.. tapi tetep inget.. biar gampang pake CTRL+H aja.. buat nama variable2 yang panjang ke nama yang lebih pendek... (Replace) COLLISION YANG CCD! tu collision kegedean bang... | |
|
Yaden Legendary
Posts : 2056 Thanked : 17 Engine : RMVX Skill : Very Beginner Type : Artist
| Subyek: Re: [RGSS2]Minigame Tembak2 2010-11-06, 14:06 | |
| @fang: aku ni ora mudeng sekrip.. cuma tau yang P&P.. biasa lah.. nambah post.. | |
|
hart Senior
Posts : 805 Thanked : 38 Engine : Other Skill : Very Beginner Type : Developer
| Subyek: Re: [RGSS2]Minigame Tembak2 2010-11-06, 18:16 | |
| @om yaden: iya kk, lagi pengen mengasah kembali RGSS2 aja. BTW, ini bukan minigame pertama yg kubikin kok, beberapa hari yg lalu juga ada https://rmid.forumotion.net/rmvx-scripts-f8/rgss2emperor-and-slave-minigame-t2678.htm BTW, P&P itu apa ya? @om irfang: Well.. saya pribadi kurang suka menyingkat-nyingkat nama variabel.. Lagipula setau saya nama variabel ga mempengaruhi kinerja program Ya benar, collision nya cacad soalnya pake algoritma yang sangat sederhana, cuma mengecek apa posisi x dan y dari objek1 ada di antara x dan y objek 2, kalau ya, return true Yah, kelemahannya kalau gambarnya 65x65 tapi gambarnya cuma terpakai 32x32 di tengah(yg lain transparan), jadinya bakal jadi tetap dianggap bercollision deh mungkin akan saya ubah kalau ada update berikutnya, makasih | |
|