Scene Pong (Pong no RPG Maker XP)

19 de maio de 2016

Scene Pong é um script para o RPG Maker XP, cujo o autor desconheço no momento, que implementa o famoso jogo Pong num projeto desta ferramenta.

Em outras palavras, você joga uma partida de ping pong contra o computador, no estilo do antigo videogame, dentro do seu jogo do RMXP. O pong pode ser chamado, como no exemplo da demo, por um evento.

Screenshot

Pong No RPG Maker XP

Instalação

A instalação do Scene Pong é simples. Basta você inserir o código acima do “Main” e colocar uns recursos nas pastas do projecto. Convém baixar a demo que já vem com tudo prontinho, inclusive os tais gráficos.

O código segue abaixo:

#==============================================================================
# Scene Pong
#------------------------------------------------------------------------------
# The pong game
#==============================================================================

class Scene_Pong
#--------------------------------------------------------------------------
# Initialize
#--------------------------------------------------------------------------
def initialize(actor=0, enemya=1)
$pong_psy = ($game_party.actors[actor].dex / 100) + 5
$pong_esy = enemya + 5
end
#--------------------------------------------------------------------------
# Main
#--------------------------------------------------------------------------
def main
$pong_x = 304
$pong_y = 224
$pong_vx = 0
while $pong_vx < 1
$pong_vx = rand(999)/666
end
$pong_vx = 1
$pong_vy = Math.sqrt(9 - ($pong_vx * $pong_vx))
$pong_py = 224
$pong_ey = 224
Graphics.frame_rate = 120
$game_system.bgs_play(nil)
$game_system.bgm_play($data_system.battle_bgm)
@game_window = Window_Pong.new
@winner_window = Window_Winner.new
@winner_window.visible = false
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@game_window.dispose
@winner_window.dispose
Graphics.frame_rate = 40
$game_system.bgm_play($game_temp.map_bgm)
end
#--------------------------------------------------------------------------
# Update
#--------------------------------------------------------------------------
def update
@game_window.update
@winner_window.update
$pong_x += $pong_vx
$pong_y += $pong_vy
if $pong_y >= 436
$pong_vy = -$pong_vy
$pong_y = 436
end
if $pong_y <= 12
$pong_vy = -$pong_vy
$pong_y = 12
end
if $pong_x <= 20 and ($pong_y <= $pong_ey+36 and $pong_y >= $pong_ey-36)
$pong_vy = ($pong_y - $pong_ey)/15
$pong_vx = Math.sqrt(9 - ($pong_vy * $pong_vy))
$pong_vx = $pong_vx.abs
end
if $pong_x >= 588 and ($pong_y <= $pong_py+36 and $pong_y >= $pong_py-36)
$pong_vy = ($pong_y - $pong_py)/15
$pong_vx = Math.sqrt(9 - ($pong_vy * $pong_vy))
$pong_vx = -$pong_vx.abs
end
if $pong_x >= 608 or $pong_x <= 0
@winner_window.visible = true
@winner_window.set_winner("You Win!")
$game_system.me_play($data_system.battle_end_me)
if $pong_x >= 608
@winner_window.set_winner("I Win!")
$game_system.me_play($data_system.gameover_me)
end
$game_system.bgm_play(nil)
loop do
Graphics.update
Input.update
if Input.trigger?(Input::C)
$scene = Scene_Map.new
break
end
end
end
if Input.trigger?(Input::C)
loop do
Graphics.update
Input.update
if Input.trigger?(Input::C)
break
end
end
end
if Input.trigger?(Input::B)
$scene = Scene_Map.new
end
if $pong_y >= $pong_ey
$pong_ey += $pong_esy
end
if $pong_y <= $pong_ey
$pong_ey -= $pong_esy
end
if Input.press?(Input::DOWN) and $pong_py < 448
$pong_py += $pong_psy
end
if Input.press?(Input::UP) and $pong_py > 0
$pong_py -= $pong_psy
end
end
end

#==============================================================================
# Pong Window
#------------------------------------------------------------------------------
# The window where pong is played
#==============================================================================

class Window_Pong < Window_Base
#--------------------------------------------------------------------------
# Initialize
#--------------------------------------------------------------------------
def initialize
super(0, 0, 640, 480)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
refresh
end
#--------------------------------------------------------------------------
# Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
bitmap = RPG::Cache.icon("Ball")
self.contents.blt($pong_x.round - 12, $pong_y.round - 12, bitmap, Rect.new(0, 0, 24, 24))
bitmap = RPG::Cache.picture("Enemy")
self.contents.blt(0, $pong_ey - 24, bitmap, Rect.new(0, 0, 24, 48))
bitmap = RPG::Cache.picture("Player")
self.contents.blt(600, $pong_py - 24, bitmap, Rect.new(0, 0, 24, 48))
end
#--------------------------------------------------------------------------
# Update
#--------------------------------------------------------------------------
def update
refresh
end
end

#==============================================================================
# Window Winner
#------------------------------------------------------------------------------
# The window that says who wins.
#==============================================================================

class Window_Winner < Window_Base
#--------------------------------------------------------------------------
# Initialize
#--------------------------------------------------------------------------
def initialize
super(230, 200, 180, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
end
#--------------------------------------------------------------------------
# Set winner
#--------------------------------------------------------------------------
def set_winner(winner)
self.contents.clear
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, self.width - 40, 32, winner, 1)
end
end

Mais RPG Maker XP

tamanho 820KB licençaGrátis sistemas operacionais compativeisWindows 98/98SE/Me/2000/XP/Vista/7 download link DOWNLOAD

Observação: se você gostou deste post ou ele lhe foi útil de alguma forma, por favor considere apoiar financeiramente a Gaming Room. Fico feliz só de ajudar, mas a contribuição do visitante é muito importante para que este site continua existindo e para que eu possa continuar provendo este tipo de conteúdo e melhorar cada vez mais. Clique aqui e saiba como. Obrigado!

Deixe um comentário

Inscreva-se na nossa newsletter!