class Tardvig::Act
@abstract Represents the abstract part of your game.
It may be anything, depends on your realization: level, location, cut-scene, credits, etc.
Public Class Methods
act_type(type = nil)
click to toggle source
@overload act_type
(type)
@param type [String, Symbol] set your custom act type. This is needed for your display to differ acts and correspondingly intepret them.
@overload act_type
@return type of your act
# File lib/tardvig/act.rb, line 12 def act_type(type = nil) if type @type = type elsif @type @type elsif superclass.respond_to? :act_type superclass.act_type end end
subject(value = nil)
click to toggle source
@overload subject(value)
If there was MVC, I would say act is a model, subject is its data and other part of act is business logic. But there is no MVC, so *subject is the content of your act and the methods of the act should process it*. For example, if your act is a location of FPS, subject is the location file and methods of your act should control player's enemies. If act is a cut-scene, subject is the video file (probably name of the file). @param value [Object] subject of your act.
@overload subject
@return [Object] subject of your act
# File lib/tardvig/act.rb, line 35 def subject(value = nil) if value @subject = value else @subject end end
Private Instance Methods
display_format()
click to toggle source
This method should return the object which will be sent to the display. By default it returns the subject. But you can redefine it. @!visibility public
# File lib/tardvig/act.rb, line 65 def display_format self.class.subject end
execute()
click to toggle source
# File lib/tardvig/act.rb, line 49 def execute notify_display process end
notify_display()
click to toggle source
This method notifies your display via GameIO
when the act is executed. You can redefine it if you want to send another message or do not want to send anything. @!visibility public
# File lib/tardvig/act.rb, line 58 def notify_display io.happen :act_start, type: self.class.act_type, subject: display_format end
process()
click to toggle source
# File lib/tardvig/act.rb, line 46 def process end