(07-17-2012, 07:46 PM)Neoz Kaho Wrote: อันนี้ผมแนะนำให้ลิสท์เลยดีกว่าว่าใส่สคริปต์อะไรลงไปมั่ง บางทีมันไม่ได้เสียที่ตรงสคริปต์ส่วนที่มันแจ้งหรอกงับ (ในที่นี้ก็คือ Bitmap) ผมว่ามันเกิดขึ้นจากการที่เราใส่มากเกินไปจนมันซ้ำซ้อน เลยพังไปเลย วิธีแก้ผมแนะนำให้เอาออกทีละตัวจนกว่าจะเข้าเกมได้ แล้วจะได้หาตัวที่ทำเสียได้งับ
Console Output
Code:
#==============================================================================
# ** Inner Console Output
#==============================================================================
if false
if $DEBUG || $TEST
# Create a console object and redirect standard output to it.
Win32API.new('kernel32', 'AllocConsole', 'V', 'L').call
$stdout.reopen('CONOUT$')
# Find the game title.
ini = Win32API.new('kernel32', 'GetPrivateProfileString','PPPPLP', 'L')
title = "\0" * 256
ini.call('Game', 'Title', '', title, 256, '.\\Game.ini')
title.delete!("\0")
# Set the game window as the top-most window.
hwnd = Win32API.new('user32', 'FindWindowA', 'PP', 'L').call('RGSS Player', title)
Win32API.new('user32', 'SetForegroundWindow', 'L', 'L').call(hwnd)
# Set the title of the console debug window'
Win32API.new('kernel32','SetConsoleTitleA','P','S').call("#{title} : Debug Console")
# Draw the header, displaying current time.
dim = [32, 32, 256, 480]
console = Win32API.new('kernel32', 'GetConsoleWindow', 'V', 'L').call
swp = Win32API.new('user32', 'SetWindowPos', 'LLIIIII', 'I')
swp.call(console, 0, dim[0], dim[1], dim[2] + 6, dim[3] + 26, -1)
end
alias zer0_console_inspect puts
def puts(*args)
inspected = args.collect {|arg| arg.inspect.gsub(',') { "\n" } }
zer0_console_inspect(*inspected)
end
end
Structure (กึ่งคิดเอง)
Code:
#==============================================================================
# ** Structure
#==============================================================================
Size = Struct.new(:width, :height)
Point = Struct.new(:x, :y)
ICurve (คิดเอง)
Code:
#==============================================================================
# ** ICurve
#------------------------------------------------------------------------------
# This module is for the more movement than Linear
#==============================================================================
module ICurve
#--------------------------------------------------------------------------
# * Accelerate
#--------------------------------------------------------------------------
def self.accelerate(t, f = 2)
t.abs ** f
end
#--------------------------------------------------------------------------
# * Decelerate
#--------------------------------------------------------------------------
def self.decelerate(t, f = 2)
1 - (t - 1).abs ** f
end
#--------------------------------------------------------------------------
# * AccelerateDecelerate
#--------------------------------------------------------------------------
def self.acceleratedecelerate(t, f = 2, fx = 1.5)
if t < 0.5
2 ** ((f * fx) - 1) * t.abs ** (f * fx)
else
1 - 2 ** ((f * fx) - 1) * (t - 1).abs ** (f * fx)
end
end
#--------------------------------------------------------------------------
# * Anticipate
#--------------------------------------------------------------------------
def self.anticipate(t, f = 2)
t ** 2 * ((f + 1.0) * t - f)
end
#--------------------------------------------------------------------------
# * Overshoot
#--------------------------------------------------------------------------
def self.overshoot(t, f = 2)
(t - 1) ** 2 * ((f + 1) * (t - 1) + f) + 1.0
end
#--------------------------------------------------------------------------
# * AnticipateOvershoot
#--------------------------------------------------------------------------
def self.anticipateovershoot(t, f = 2, fx = 1.5)
if(t < 0.5)
0.5 * self.anticipate(t * 2, f * fx)
else
0.5 * (self.overshoot(t * 2 - 1, f * fx) + 1)
end
end
#--------------------------------------------------------------------------
# * Smooth Bounce
#--------------------------------------------------------------------------
def self.smoothbounce(t, b = 5)
1 - self.accelerate(t - 1) * Math.sin(Math::PI * (b + 0.5) * (t - 1)).abs
end
#--------------------------------------------------------------------------
# * Smooth Wobble
#--------------------------------------------------------------------------
def self.smoothwobble(t, b = 5)
1 - self.accelerate(t - 1) * Math.sin(Math::PI * (2 * b - 0.5) * (t - 1))
end
end
Graphics (กึ่งคิดเอง)
Code:
#==============================================================================
# ** Graphics
#==============================================================================
module Graphics
#--------------------------------------------------------------------------
# * Pause Animation (NOT 'sleep' Function)
#--------------------------------------------------------------------------
def self.pause(t)
while t > 0
self.update
end
end
#--------------------------------------------------------------------------
# * FPS and MSPF
#--------------------------------------------------------------------------
@Fps = self.frame_rate
@Mspf = [1000.0 / @Fps]
@Mspf_Size = self.frame_rate
def self.FPS
1000.0 / self.MSPF
end
def self.MSPF
mspf = 0
for i in @Mspf
mspf += i.to_f
end
mspf /= @Mspf.size
return mspf
end
#--------------------------------------------------------------------------
# * Update
#--------------------------------------------------------------------------
class << self
alias admannon_graphic_update update
end
def self.update
if @Mspf.size < @Mspf_Size
@Mspf.push(Time.now)
else
@Mspf.reverse!.pop
@Mspf.reverse!.push(Time.now)
end
admannon_graphic_update
@Mspf[@Mspf.size - 1] = Time.now - @Mspf[@Mspf.size - 1]
@Mspf[@Mspf.size - 1] = @Mspf[@Mspf.size - 1] * 1000 + 3
end
end
ยิ่งลบยิ่งเจอ แก้ไม่ถูก