Aldeia RPG

Gostaria de reagir a esta mensagem? Crie uma conta em poucos cliques ou inicie sessão para continuar.

Suporte ao desenvolvimento de jogos


4 participantes

    Minigame - Quicar a Bola

    RD12
    RD12
    Lenda
    Lenda


    Medalhas : Minigame - Quicar a Bola 48080450Minigame - Quicar a Bola Trophy11Minigame - Quicar a Bola GIueZMinigame - Quicar a Bola ZgLkiRU
    Mensagens : 1946
    Créditos : 745

    Minigame - Quicar a Bola Empty Minigame - Quicar a Bola

    Mensagem por RD12 Sex Fev 15, 2013 1:29 pm

    Minigame de Quicar a Bola
    Esse minigame é de quicar a bola com o mouse, se a bola cair no chão, você perde, quanto mais tempo quicando ela, mais pontos você consegue. No final os pontos são convertidos em moedas ou experiência.
    Foi usado um script de mouse feito por mim.


    Imagens

    Spoiler:

    Mouse

    Código:
    #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
    #|Autor: RD12|              Mouse System
    #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
    #$Mouse.icon_drag = "Picture" #Poe um icone em baixo do mouse
    #como se estivesse arrastando.
    #$Mouse.icon_cursor = "Picture" #Muda o cursor do mouse

    class Game_Mouse
     
      attr_accessor :x
      attr_accessor :y
      attr_accessor :icon_cursor
      attr_accessor :icon_drag
      attr_accessor :left
      attr_accessor :map_x
      attr_accessor :map_y
      def initialize
        Win32API.new("user32", "ShowCursor", "i", "i" ).call(0)
        @x = 0
        @y = 0
        @map_x = 0
        @map_y = 0
        @pos = 0
        @icon_cursor = "Cursor"
        @icon_drag = ""
        @cursor = Sprite.new
        @cursor.z = 999999999
        @cursor_drag = Sprite.new
        @cursor_drag.z = 999999998
        @left_up = false
        @click_count = 0
        #Windows API's
        @GetCursorPos = Win32API.new("user32", "GetCursorPos", ['P'], 'V')
        @ScrToClt = Win32API.new('user32', 'ScreenToClient', ['l','p'], 'i')
        @GPPS = Win32API.new('kernel32', 'GetPrivateProfileStringA', %w(p p p p l p), 'l')
        @FindWindow = Win32API.new('user32', 'FindWindowA', ['p', 'p'], 'l')
        @x_count = 0
      end
     
      def update
        @x_count += 1
        if @x_count == 3
        @old_x = @x
        @old_y = @y
        @x_count = 0
      end
        @cursor.bitmap = RPG::Cache.icon(@icon_cursor)
        @cursor_drag.z = 1
        @cursor_drag.bitmap = RPG::Cache.icon(@icon_drag)
        @x, @y = scr_to_cl(*global_pos)
        return if @x.nil? or @y.nil?
        @cursor.x, @cursor.y = @x, @y
      end
         
      def left_press
      if Win32API.new("user32", "GetAsyncKeyState", "i", "i").call(1) != 0
        return true
      else
        return false
      end
      end
     
      def right_press
      if Win32API.new("user32", "GetAsyncKeyState", "i", "i").call(2) != 0
        return true
      else
        return false
      end
      end

      def global_pos
        lpp = " " * 8
        @GetCursorPos.Call(lpp)
        x, y = lpp.unpack("LL")
        return x, y
      end
     
      def scr_to_cl(x, y)
        return nil unless x and y
        pos = [x, y].pack('ll')
        if @ScrToClt.call(win_h, pos) != 0
          return pos.unpack('ll')
        else
          return nil
        end
      end
     
      def win_h
        game_name = "\0" * 256
        @GPPS.call('Game','Title','',game_name,255,".\\Game.ini")
        game_name.delete!("\0")
        return @FindWindow.call('RGSS Player',game_name)
      end
       
      def in_area?(x, y, w, h)
        return if @x.nil? or @y.nil?
        if ($Mouse.x >= x and $Mouse.x <= (x+w)) and ($Mouse.y >= y and $Mouse.y <= (y+h))
          return true
        else
          return false
        end
      end
     
    end

    Minigame

    Código:
    #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
    #Author: RD12          Minigame de quicar a bola
    #------------------------------------------------------------------
    #Para iniciar o jogo chame o script: $scene = Scene_BallGame.new
    #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

    module Config_BallGame
      #==O valor que irá ganhar é igual ao número vezes a pontuação==
      Ganhar_Moedas = [true,10]#true para ganhar, número
      Ganhar_XP = [true,5]#true para ganhar, número
      #Tempo para aumentar o ponto
      Time_Ponto = 60
      Fundo = "001-Title01"
      #Física
      Gravidade = 12
      Atrito = 0.9
    end

    class Scene_BallGame
      def main
        @sprite = Sprite.new
        @sprite.bitmap = RPG::Cache.title(Config_BallGame::Fundo)
        @Ball = Ball_Minigame.new
        @Hud_Ball = Hud_Ball.new
        $Mouse = Game_Mouse.new
        @count = 0
        Graphics.transition
        loop do
          $Mouse.update
          Graphics.update
          Input.update
          update
          if $scene != self
            break
          end
        end
        Graphics.freeze
        @sprite.bitmap.dispose
        @sprite.dispose
        @Hud_Ball.dispose
        @Ball.dispose
      end
     
      def update
        @count += 1
        if !$perdeu and @count == Config_BallGame::Time_Ponto
          $pontos += 1
          @count = 0
        end
        @Hud_Ball.refresh
        if Input.trigger?(Input::C)
          $start_ball = true
          $scene = Scene_Map.new if $perdeu
        end
       
        @Ball.update
      end
    end
    class Ball_Minigame < Sprite
      def initialize
        super()
        self.bitmap = Bitmap.new(92,92)
        self.x = 640/2-45
        self.y = 50
        self.z = 10
        @grav = Config_BallGame::Gravidade
        @atrito = Config_BallGame::Atrito
        @vel_y = 0
        @vel_x = 0
        @ball = RPG::Cache.picture("Ball")
        $start_ball = false
      end
     
      def update
        self.bitmap.clear
        self.bitmap.blt(0, 0, @ball, Rect.new(0, 0, @ball.width, @ball.height))
        return unless $start_ball
        fisica
        if $Mouse.left_press and !$perdeu
          if $Mouse.in_area?(self.x,self.y, 44, 92)
            @vel_x = 5 * @grav
            @vel_y = -15 * @grav
          end
          if $Mouse.in_area?(self.x+45,self.y+40, 40, 40)
            @vel_x = -5 * @grav
            @vel_y = -15 * @grav
          end
        end
      end
     
      def fisica
        @vel_y += @grav
        @vel_x += 0
        self.x += @vel_x/10
        self.y += @vel_y/10
        if self.y >= 480-90
          return if @vel_y < 0
          @vel_y *= -@atrito
          $perdeu = true
        end
        if self.y <= 0
          @vel_y = 20
        end
        if self.x >= 640-90
          return if @vel_x < 0
          @vel_x *= -@atrito
        end
        if self.x <= 0
          @vel_x *= -@atrito
        end
      end
    end

    class Hud_Ball < Sprite
     
      def initialize
        super()
        self.bitmap = Bitmap.new(640,100)
        self.x = 0
        self.y = 10
        self.z = 10
        $pontos = 0
        @count = 0
      end
     
      def refresh
        self.bitmap.clear
        unless $start_ball
          self.bitmap.draw_text(0,0,640,25,"Aperte Enter para começar",1)
        else
          self.bitmap.draw_text(0,0,640,25,"Pontuação: #{$pontos}",1)
        end
        if $perdeu
          self.bitmap.draw_text(0,40,640,25,"Você deixou a bola cair - Enter para voltar",1)
          @ganhou = ""
          if Config_BallGame::Ganhar_Moedas[0]
            @ganhou += " #{$pontos*Config_BallGame::Ganhar_Moedas[1]} Moedas e"
          end
          if Config_BallGame::Ganhar_XP[0]
            @ganhou += " #{$pontos*Config_BallGame::Ganhar_XP[1]} Exp"
          end
          self.bitmap.draw_text(0,60,640,25,"Ganhou: #{@ganhou}",1)
         
        end
      end
    end

    Imagens necessários:
    Ball - Pasta Pictures
    Minigame - Quicar a Bola AgCfGDv
    https://i.imgur.com/agCfGDv.png
    Cursor - Pasta Icons
    Minigame - Quicar a Bola GvrQBHd
    https://i.imgur.com/GvrQBHd.png

    Créditos: RD12
    heyitily
    heyitily
    Experiente
    Experiente


    Mensagens : 421
    Créditos : 12

    Minigame - Quicar a Bola Empty Re: Minigame - Quicar a Bola

    Mensagem por heyitily Sex Fev 15, 2013 2:03 pm

    Shoow :-D


    _________________
    Minigame - Quicar a Bola SICBb4n
    DeaN
    DeaN
    Colaborador
    Colaborador


    Mensagens : 1243
    Créditos : 48

    Minigame - Quicar a Bola Empty Re: Minigame - Quicar a Bola

    Mensagem por DeaN Sex Fev 15, 2013 2:05 pm

    Bem Legal RD e bem interessante.
    1+


    _________________
    Dean, Programador Geral :)

    Contato: Skype:matucarvalho e Facebook
    The Enze - Vulzt

    Shield Block
    Anti-Cheat para jogos de FPS, agora vou adaptar para jogos de RPG principalmente para o RMXP.
    www.shieldblock.net
    fb.com/shieldblockoficial

    Minigame - Quicar a Bola MiB0H
    Laxus
    Laxus
    Aldeia Friend
    Aldeia Friend


    Mensagens : 1150
    Créditos : 78

    Minigame - Quicar a Bola Empty Re: Minigame - Quicar a Bola

    Mensagem por Laxus Sex Fev 15, 2013 4:12 pm

    Bem bolado cara kkkk gostei essa foi uma otima ideia XD


    _________________
    "Não importa o quão forte o cara é, o que importa é encara-lo de frente sem fraquejar"
                                                                                                                                                        Laxus ~ Fairy Tail

    Conteúdo patrocinado


    Minigame - Quicar a Bola Empty Re: Minigame - Quicar a Bola

    Mensagem por Conteúdo patrocinado


      Data/hora atual: Seg maio 20, 2024 11:20 am