working on reimplimenting server
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
# Nathan Hinton 19 Dec 2025
|
||||
|
||||
|
||||
require 'yaml'
|
||||
|
||||
# Base class for any object in space. This can be a planet, asteroid, ship etc.
|
||||
class SpaceObject
|
||||
attr_reader :position
|
||||
|
||||
File.open('./config.yaml', 'r') do |fi|
|
||||
@@config = YAML.safe_load(fi.read())
|
||||
end
|
||||
|
||||
# Create the object
|
||||
#
|
||||
def initialize()
|
||||
@position = [0, 0, 0]
|
||||
end
|
||||
|
||||
# Delete the object. This should be overwritten by the sub objects. For
|
||||
# example when an asteroid is destroyed it might want to explode and damage
|
||||
# anything nearby first before being removed from the game. This is the path
|
||||
# that will be used for that.
|
||||
def delete()
|
||||
end
|
||||
|
||||
# Move the object to a new position. Not everything should be movable so this
|
||||
# can be disallowed by sub classes.
|
||||
#
|
||||
# @param position [Array<Integer>] The position that the object should be
|
||||
# moved to.
|
||||
def move(position)
|
||||
@position = position
|
||||
end
|
||||
|
||||
# This *should* be overridden by any object that wants to do anyting. For
|
||||
# example a ship probaly would like to move when the game tick happens.
|
||||
def tick()
|
||||
end
|
||||
|
||||
# Define a method to get the config
|
||||
#
|
||||
# @return [Hash] A hash containing the configuration
|
||||
def get_config()
|
||||
return @@config
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user