- Joined
- Dec 16, 2012
- Messages
- 42
- Reaction score
- 25
- First Language
- French
- Primarily Uses
2 Arcade minigame i've made some day ago,i was planning doing more games but i don't know.
Here a video :
https://www.youtube.com/watch?v=JQSg2LkfJhg
Here the scripts :
Images Creations for numbers and class modifying (Needed to run the 2 other script)
Pong
Space Explorer
Here a video :
https://www.youtube.com/watch?v=JQSg2LkfJhg
Here the scripts :
Images Creations for numbers and class modifying (Needed to run the 2 other script)
Code:
#==============================================================================# ** Game_Images#------------------------------------------------------------------------------# This Module handles Image Creations. #==============================================================================module Game_Images #-------------------------------------------------------------------------- # * Numbers #-------------------------------------------------------------------------- def self.zero b = Bitmap.new(6,12) b.fill_rect(b.rect, Color.new(255,255,255)) b.clear_rect(2,2,2,8) return b end def self.one b = Bitmap.new(6,12) b.fill_rect(4,0,5,12, Color.new(255,255,255)) return b end def self.two b = Bitmap.new(6,12) b.fill_rect(b.rect, Color.new(255,255,255)) b.clear_rect(0,2,4,3) b.clear_rect(2,7,4,3) return b end def self.three b = Bitmap.new(6,12) b.fill_rect(b.rect, Color.new(255,255,255)) b.clear_rect(0,2,4,3) b.clear_rect(0,7,4,3) return b end def self.four b = Bitmap.new(6,12) b.fill_rect(b.rect, Color.new(255,255,255)) b.clear_rect(2,0,2,5) b.clear_rect(0,7,4,5) return b end def self.five b = Bitmap.new(6,12) b.fill_rect(b.rect, Color.new(255,255,255)) b.clear_rect(2,2,4,3) b.clear_rect(0,7,4,3) return b end def self.six b = Bitmap.new(6,12) b.fill_rect(b.rect, Color.new(255,255,255)) b.clear_rect(2,0,5,5) b.clear_rect(2,7,2,3) return b end def self.seven b = Bitmap.new(6,12) b.fill_rect(b.rect, Color.new(255,255,255)) b.clear_rect(0,2,4,10) return b end def self.eight b = Bitmap.new(6,12) b.fill_rect(b.rect, Color.new(255,255,255)) b.clear_rect(2,2,2,3) b.clear_rect(2,7,2,3) return b end def self.nine b = Bitmap.new(6,12) b.fill_rect(b.rect, Color.new(255,255,255)) b.clear_rect(2,2,2,3) b.clear_rect(0,7,4,5) return b end def self.nbrstripe b = Bitmap.new(60,12) bb = self.zero b.blt(0, 0,bb ,bb.rect) bb = self.one b.blt(6, 0,bb ,bb.rect) bb = self.two b.blt(12, 0,bb ,bb.rect) bb = self.three b.blt(18, 0,bb ,bb.rect) bb = self.four b.blt(24, 0,bb ,bb.rect) bb = self.five b.blt(30, 0,bb ,bb.rect) bb = self.six b.blt(36, 0,bb ,bb.rect) bb = self.seven b.blt(42, 0,bb ,bb.rect) bb = self.eight b.blt(48, 0,bb ,bb.rect) bb = self.nine b.blt(54, 0,bb ,bb.rect) return b end end#==============================================================================# ** Bitmap Class#------------------------------------------------------------------------------# Modify the Bitmap class to draw our new number#==============================================================================class Bitmap def draw_custom_text(text,x,y) b = Game_Images.nbrstripe for i in 0..text.size-1 if (text[i].ord >= 48 && text[i].ord <= 57) blt(x+(i*7), y, b, Rect.new((text[i].ord-48)*6,0,6,12)) end end endend#==============================================================================# ** Sprite Class#------------------------------------------------------------------------------# Modify the Bitmap class to add Bounding Box method#==============================================================================class Sprite def boundingbox() return Rect.new(x,y,src_rect.width,src_rect.height) endend
Pong
Code:
#==============================================================================#Pong V0.1#Author : Zarby - No Credit Required, free to use#Rule first to score 10 point win#==============================================================================#==============================================================================# ** Game_Images#------------------------------------------------------------------------------# This Module handles Image Creations. #==============================================================================module Game_Images #-------------------------------------------------------------------------- # * Paddle Image #-------------------------------------------------------------------------- def self.paddle b = Bitmap.new(8,32) b.fill_rect(b.rect, Color.new(255,255,255)) return b end #-------------------------------------------------------------------------- # * Ball Image #-------------------------------------------------------------------------- def self.ball b = Bitmap.new(8,8) b.fill_rect(b.rect, Color.new(255,255,255)) return b end end#==============================================================================# ** Scene_Pong#------------------------------------------------------------------------------# This Class perform the game processing "Pong"#==============================================================================class Scene_Pong < Scene_Base #-------------------------------------------------------------------------- #DIFFICULTY SETTING Difficulty = 15 #12 = Very Easy,14 = Easy, 16 = Hard, 18 = Very Hard, 20 Impossible #0 = AI wont move at all, 10 = AI Move 1 on 2, 20 = AI Follow the ball #VARIABLE RETURN IF WIN OR NOT ReturnVariable = 10 #IF we win the variable will = 1, if we loose variable = 0 / -1 if leave #-------------------------------------------------------------------------- #-------------------------------------------------------------------------- # * Start Processing #-------------------------------------------------------------------------- def start super set_score add_sprite reset_ball @ai_move = 0 @ai_timer = 0 @pause = false end def add_sprite @player_paddle = Sprite.new() @cpu_paddle = Sprite.new() @ball = Sprite.new() @player_paddle.bitmap = Game_Images.paddle @cpu_paddle.bitmap = Game_Images.paddle @ball.bitmap = Game_Images.ball @player_paddle.x = 16 @player_paddle.y = 220 @cpu_paddle.x = 520 @cpu_paddle.y = 220 @ball.x = 268 @ball.y = 204 @scorep1_spr = Sprite.new() b = Bitmap.new(24,12) b.draw_custom_text(sprintf('%02d',@scorep1),0,0) @scorep1_spr.bitmap = b @scorep1_spr.zoom_x = 2 @scorep1_spr.zoom_y = 2 @scorep1_spr.x = 120 @scorep1_spr.y = 8 @scorep2_spr = Sprite.new() b = Bitmap.new(24,12) b.draw_custom_text(sprintf('%02d',@scorep2),0,0) @scorep2_spr.bitmap = b @scorep2_spr.zoom_x = 2 @scorep2_spr.zoom_y = 2 @scorep2_spr.x = 544-120 @scorep2_spr.y = 8 @timer_spr = Sprite.new() @timer_spr.x = 260 end def set_score @scorep1 = 0 @scorep2 = 0 end def reset_ball @timer = 3 @bugtimer = 0 @real_timer = 120 @started = false @ball_speed = 4 @real_ball_x = 268.0 @real_ball_y = 204.0 @ball.x = @real_ball_x @ball.y = @real_ball_y @ball_direction = 0 update_score end def update_score b = Bitmap.new(24,12) b.draw_custom_text(sprintf('%02d',@scorep2),0,0) @scorep2_spr.bitmap = b b = Bitmap.new(24,12) b.draw_custom_text(sprintf('%02d',@scorep1),0,0) @scorep1_spr.bitmap = b end def update_timer if (@real_timer >= 0) @timer_spr.visible = true @real_timer -=1 @timer = @real_timer / 30 b = Bitmap.new(24,12) b.draw_custom_text(sprintf('%02d',@timer),0,0) @timer_spr.bitmap = b if (@real_timer == 0) @real_timer = -1 @timer = -1 game_start @timer_spr.visible = false end end end def game_start #Set ball direction rand = Random.new() @ball_side_x = rand.rand(0..1).to_i @ball_side_y = rand.rand(0..1).to_i @started = true @ball_direction = rand.rand(-70..70) end def update super if (@pause == false) update_timer if (@started) if (@ball_side_x == 1) @real_ball_x += @ball_speed * Math.cos(degtorad(@ball_direction)); elsif (@ball_side_x == 0) @real_ball_x -= @ball_speed * Math.cos(degtorad(@ball_direction)); end if (@ball_side_y == 1) @real_ball_y += @ball_speed * Math.sin(degtorad(@ball_direction)); elsif (@ball_side_y == 0) @real_ball_y -= @ball_speed * Math.sin(degtorad(@ball_direction)); end @ball.x = @real_ball_x @ball.y = @real_ball_y end #Bug Solver? if (@ball.y == 4) @bugtimer+=1 if (@bugtimer >= 160) reset_ball end else @bugtimer = 0 end player_control check_collision ai_control # Stupid AI end if (Input.trigger?(:X)) if (@pause == false) @pause = true elsif(@pause == true) @pause = false end end if (@scorep1 >= 10) $game_variables[ReturnVariable] = 1 dispose end if (@scorep2 >= 10) $game_variables[ReturnVariable] = 0 dispose end if (Input.press?(:) $game_variables[ReturnVariable] = -1 dispose end end def dispose @player_paddle.dispose @cpu_paddle.dispose @scorep1_spr.dispose @scorep2_spr.dispose @timer_spr.dispose #return_scene SceneManager.goto(Scene_Map) end #----------------------------------------------------------------------------- # Control if the player is pressing a key #----------------------------------------------------------------------------- def player_control if (Input.press?(:UP)) @player_paddle.y -=4 if (@player_paddle.y < 0) @player_paddle.y = 0 end end if (Input.press?(:DOWN)) @player_paddle.y +=4 if (@player_paddle.y > 416-32) @player_paddle.y = 416-32 end end end def ai_control @ai_timer += 1 rand = Random.new() if (@ai_timer >= 10) @ai_move = rand.rand(0..20)#Rand if move < 10, else > 10 @ai_timer = 0 end if (@ai_move < Difficulty) if (@ball_side_x ==1) if (@ball.y+2 < @cpu_paddle.y+16) @cpu_paddle.y-=4 end if (@ball.y+2 > @cpu_paddle.y+16) @cpu_paddle.y+=4 end if (@cpu_paddle.y < 0) @cpu_paddle.y = 0 end if (@cpu_paddle.y > 416-32) @cpu_paddle.y = 416-32 end end end end #----------------------------------------------------------------------------- # Check Collison between ball and wall, paddle #----------------------------------------------------------------------------- def check_collision if (@ball.y <= 0) @ball.y = @ball_speed if (@ball_side_y == 0) @ball_side_y = 1 elsif (@ball_side_y == 1) @ball_side_y = 0 end end if (@ball.y >= 412) @ball.y = 412 - @ball_speed if (@ball_side_y == 0) @ball_side_y = 1 elsif (@ball_side_y == 1) @ball_side_y = 0 end end if (@ball.x >= 540) @scorep1+=1 reset_ball end if (@ball.x <= 0) @scorep2+=1 reset_ball end if (rectangle_intersect(@ball.boundingbox,@player_paddle.boundingbox) == true) @ball.x = (@player_paddle.x + 4 + @ball_speed) @ball_side_x = 1 @ball_direction = (-50 + ((@ball.y+2)-@player_paddle.y)*4) if ((@ball.y+4)-@player_paddle.y) < 16 @ball_side_y = 1 end if ((@ball.y+4)-@player_paddle.y) > 16 @ball_side_y = 1 end end if (rectangle_intersect(@ball.boundingbox,@cpu_paddle.boundingbox) == true) @ball.x = (@cpu_paddle.x - 4 - @ball_speed) @ball_side_x = 0 @ball_direction = (-50 + ((@ball.y+2)-@cpu_paddle.y)*4) if ((@ball.y+4)-@cpu_paddle.y) < 16 @ball_side_y = 1 end if ((@ball.y+4)-@cpu_paddle.y) > 16 @ball_side_y = 1 end end end #----------------------------------------------------------------------------- # If 2 rectangle interset return true #----------------------------------------------------------------------------- def rectangle_intersect(r1,r2) if ((r1.x+r1.width > r2.x) && (r1.x < r2.x+r2.width) && (r1.y+r1.height > r2.y) && (r1.y < r2.y+r2.height)) return true end return false end def degtorad(deg) return (deg * Math::PI / 180) end end
Space Explorer
Code:
#==============================================================================#SpaceExplorer V0.1#Author : Zarby - No Credit Required, free to use#Go the furthest you can !#==============================================================================#==============================================================================# ** Game_Images#------------------------------------------------------------------------------# This Module handles Image Creations. #==============================================================================module Game_Images #-------------------------------------------------------------------------- # * Paddle Image #-------------------------------------------------------------------------- def self.spaceship b = Bitmap.new(16,8) b.fill_rect(1,1,3,1, Color.new(255,255,255)) b.fill_rect(5,1,2,1, Color.new(255,255,255)) b.fill_rect(7,0,2,2, Color.new(255,255,255)) b.fill_rect(9,0,2,1, Color.new(255,255,255)) b.fill_rect(11,1,2,1, Color.new(255,255,255)) b.fill_rect(13,2,1,1, Color.new(255,255,255)) b.fill_rect(14,3,1,3, Color.new(255,255,255)) b.fill_rect(4,5,10,2, Color.new(255,255,255)) b.fill_rect(2,2,8,4, Color.new(255,255,255)) b.fill_rect(6,4,5,4, Color.new(255,255,255)) b.fill_rect(1,3,1,1, Color.new(255,255,255)) b.fill_rect(1,5,1,1, Color.new(255,255,255)) return b end #272x208 x2end#==============================================================================# ** Scene_SpaceExplorer#------------------------------------------------------------------------------# This Class perform the game processing "SpaceExplorer"#==============================================================================class Scene_SpaceExplorer < Scene_Base #-------------------------------------------------------------------------- #SETTINGS ReturnVariable = 10 #Return the score to the variable #-------------------------------------------------------------------------- #-------------------------------------------------------------------------- # * Start Processing #-------------------------------------------------------------------------- def start super @map = [] @space_between = 32 create_map create_sprites @score = 0 @lastvalue = 104 @lastdirectiontimer = 0 @lastdirection = 0 @scoretimer = 0 @deadtimer = 0 @pause = false @dead = false end def create_sprites @spaceship_spr = Sprite.new() b = Bitmap.new(32,16) b.stretch_blt(Rect.new(0,0,32,16), Game_Images.spaceship, Rect.new(0,0,16,8)) @bgr_bitmap = Bitmap.new(288,208) @bgr_spr = Sprite.new() @spaceship_spr.bitmap = b @spaceship_spr.x = 16*2 @spaceship_spr.y = 104*2 @sprite_score = Sprite.new @sprite_score.x = 544/2-(5*7) @sprite_score.y = 400 update_image end #-------------------------------------------------------------------------- # * Update Processing #-------------------------------------------------------------------------- def update super if (@pause == false) @bgr_spr.x-=4; @scoretimer+=1 if (@scoretimer >= 15) @score+=1 @scoretimer = 0 b = Bitmap.new(64,16) b.fill_rect(0,0,64,16,Color.new(0,0,0)) b.draw_custom_text(sprintf('%08d',@score),4,2) @sprite_score.bitmap = b end if ((@spaceship_spr.y / 2) <= (@map[2]-@space_between)) @pause = true @dead = true end if ((@spaceship_spr.y / 2) <= (@map[3]-@space_between)) @pause = true @dead = true end if ((@spaceship_spr.y / 2)+8 >= (@map[2]+@space_between)) @pause = true @dead = true end if ((@spaceship_spr.y / 2)+8 >= (@map[3]+@space_between)) @pause = true @dead = true end if (@bgr_spr.x <=-16) update_map update_image @bgr_spr.x = 0 end player_control else if (@dead == true) @deadtimer +=1 if (@deadtimer == 120) dispose end end end if (Input.trigger?(:X)) if (@pause == false) @pause = true elsif(@pause == true) @pause = false end end end#update end def create_map m = 0 for i in 0..36 @map[i] = 104 end end def dispose $game_variables[ReturnVariable] = @score @bgr_spr.dispose @spaceship_spr.dispose @sprite_score.dispose SceneManager.goto(Scene_Map) end def update_map @space_between = 32 @lastdirectiontimer+=1 rand = Random.new() if (@lastdirectiontimer >=rand.rand(0..3)) a = rand.rand(-1..1) @lastdirection = 0 if (a == -1) if (@lastvalue >= @space_between+8) @lastvalue-=4; @lastdirection = -1 else @lastdirection = 1 end end if (a == 1) if (@lastvalue <= 180-@space_between) @lastvalue+=4; @lastdirection = 1 else @lastdirection = -1 end end @lastdirectiontimer = 0 end r = rand.rand(0..100) if (@lastdirection == -1) @lastvalue-=4 if (r >= 75) @lastvalue-=4 end end if (@lastdirection == 1) @lastvalue+=4 if (r >= 75) @lastvalue+=4 end end oldmap = @map for i in 0..36 if (i != 36) @map[i] = oldmap[i+1] else @map[i] = @lastvalue end end end #----------------------------------------------------------------------------- # Control if the player is pressing a key #----------------------------------------------------------------------------- def player_control if (Input.press?(:UP)) @spaceship_spr.y -=2 if (@spaceship_spr.y < 0) @spaceship_spr.y = 0 end end if (Input.press?(:DOWN)) @spaceship_spr.y +=2 if (@spaceship_spr.y > 416-8) @spaceship_spr.y = 416-8 end end end def update_image @bgr_bitmap = Bitmap.new(288,208) for i in 0..36 mn = (@map[i]-@space_between) mp = (@map[i]+@space_between) @bgr_bitmap.fill_rect(i*8,0,8,mn,Color.new(132,68,20)) @bgr_bitmap.fill_rect(i*8,mp,8,288-mp,Color.new(132,68,20)) end stretchedbmp = Bitmap.new(576,416) stretchedbmp.stretch_blt(Rect.new(0,0,576,416), @bgr_bitmap, Rect.new(0,0,288,208)) @bgr_spr.bitmap = stretchedbmp end end

