Temple of The Roguelike Forums
Development => Programming => Topic started by: SarahW on May 24, 2016, 06:04:11 PM
-
I tried looking for specifics in a startpage search, but usually when I look up specific things Stack Overflow often gives confusing answers without really explaining how anything works, and then I have figure out how to rework things to fit in a game design concept. Very frustrating.
Anyway, what I mainly know of Ruby is strings, variables, arrays, class, class call. I have difficulty with more specific grhings like reading files, so I often end up having to hard code levels in.
Is there a way to find tutorials written in a way that don't feel like machine level language? That way I can better find out the extent of which specific loops in Ruby are necessary.
class Hello
def initialize
greet
end
def greet
puts "Hello Roguelike Forums."
end
end
Hello.new
Mostly used to novels, so this has been an ... interesting experience so far.
-
Free version of the book:
http://learnrubythehardway.org/book/index.html
-
Ruby code usually uses the `each` method on collections instead of explicit loops.
items = ["sword", "shield", "armor"]
items.each do |item|
puts item
end
-
Ruby code usually uses the `each` method on collections instead of explicit loops.
items = ["sword", "shield", "armor"]
items.each do |item|
puts item
end
Thanks! I'll look into that.
I am familiar with things like:
20.times do
puts "Hello World."
end
So I'll be sure to test it out!
-
There is also more classic
while condition
...
end
for algorithms
and even infinite
loop do
...
end
for things like a main game loop.
-
Would that be like for a game engine?
One of the first text based games (not going to say it's roguelike, cause ... well it's not.) was a hybrid of text based adventure and an early navigational style. I've sense learned better methods (not pun intended) like assigning tiles to variables and navigating based on a game loop in a game class.
Note to self, contains navigation in one method.
Central Hud is what I use for more statistics based games. It's closer to a text based "dating sim" than a roguelike.
-
These AI bots are getting interesting. It's almost making some kind of sense.
-
Yup. Too bad our local flame bot can't muster anything reminiscent of intelligence, though.
As always,
Minotauros
-
Yea, I've read this thread a dozen times and I still can't tell if SarahW is a bot. It's hard to believe that some of the sentences are from a bot, but other sentences are pretty incoherent. Maybe it's some combo of markov generation and a human writing? No idea.
Anyway, loops are one of the most fundamental constructs in programming. I can't image doing much useful without them, especially for games programming. And they're pretty easy too.
My biggest problem with loops is when I often try to delete out of array I'm looping over. Only works if the loop runs in reverse.