Not logged inGosu Forums
Forum back to Help Search Register Login
Up Topic Gosu / Gosu Showcase / Blocks 2D (in development)
- - By jahmaican Date 2013-05-15 20:18 Edited 2013-06-16 16:20

Hi! I'm relatively new to Gosu and Ruby in general, but still wanted to show my first creation.

What's new?
Added jumping (finally!).
I'll probably rewrite the whole thing for Chingu some time soon.

What is it?
Intended to be a 2D Minecraft clone. Still needs a lot of effort.

What's done?
Drawing a 3-layer map, basic movement, very simple physics, basic building.

What has to be done?
Improving movement.
Introducing bigger maps with scrolling; storing them in more friendly format maybe.
Creative mode just like in real Minecraft + flat map generation.
GUIs, menus etc.
Actually learning how to Ruby.
Then maybe some proper mining and crafting.

How do I play?
Left/A, right/D - move left/right.
Up/W -jump.
Left click, right click - destroy/place blocks.
1, 2, 3 - choose material.
Middle click - teleport.
Escape - exit.

What was used?
Tiled editor - the map you see can be easily edited.
Coterie Craft Minecraft texture pack.
My Minecraft skin.

0.15 Right here!
Github page

Go on, share your thoughts and opinions.
Parent - - By ExplodingCookie Date 2013-05-15 22:52
Image looks good. Unfortunately, I use only Macs. Therefore I cannot try it out due to this apparently being windows only. Nice work for your first time with Gosu and Ruby, welcome aboard!
Parent - - By jahmaican Date 2013-05-16 10:38
Source is included in the package so you can run it yourself :)
Parent - - By ExplodingCookie Date 2013-05-16 16:51
Oh, I could not find which file to execute in the source.
Parent - By Spooner Date 2013-05-17 08:54
Parent - By jlnr (dev) Date 2013-05-21 06:22
...and you need Ruby 1.9 & the xml-simple gem :)
Parent - By SeamusFD Date 2013-05-16 19:56
Hey guys... I really like the idea of this game, I really do. However I, (like ExplodingCookie) have the problem of only having access to mac's. However I think I figured out what to do and I attempted to install xml-simple and gosu (this is my first time running gosu on a particular computer,) however when I try to run the program through my code editor I come up with this error...

warning: already initialized constant VERSION
LoadError: no such file to load — gosu

method gem_original_require  in custom_require.rb at line 31
method require  in custom_require.rb at line 31
at top level  in tiled.rb at line 10
Program exited with code #1 after 0.21 seconds.

I am so confused :(
Could someone please help me...
Parent - - By Spooner Date 2013-05-16 11:25
Looks interesting so far! Glad you got some use from Releasy's :windows_folder builder!

I'd recommend you look at a higher level Gosu framework, such as Gamebox or Chingu, to make things easier for you once you add more functionality.

A few comments on the code, to help you along with Ruby in general:

Rather than using if/then/end on one line, we generally use the single conditional postfix this way:
close if button_down? KbEscape

Use two spaces rather than hard tab. Makes your code look a lot nicer when viewed online too.

if @obrot == :prawo then
We don't usually use then; It just isn't necessary. Also, that bit is crying out to be a case statement.

Rather than use your own #debug method, use Logger (standard library) or Log4r (gem) for logging.

for i in 0..2 do => (0..2).each do |i| (Although for might feel better if you are coming from another language, it is extremely limiting once you try to do a bit more with Ruby)

def block?(x,y); @map_main[(y/32)][(x/32)] != 0; end

Use ?: over if/then/else/end on one line (or put it on multiple lines).

print("%H:%M:%S.%L") + " - " + message.to_s + "\n") => puts "#{"%H:%M:%S.%L")} - #{message}" (although I suggested using a logger for this).
Parent - - By jahmaican Date 2013-05-16 14:12
You're right, I used other languages before and I'm not quite familiar with Ruby syntax yet. Thanks for the helpful post!
Parent - - By Spooner Date 2013-05-17 09:18
Oh, I'd also highly recommend using the bundler gem to manage the gems you need for your project.

#set & #show are a bit convoluted. Try:
attr_accessor :speed, :gravity, :x, :y

def pos; [@x, @y]; end
def pos=(value); @x, @y = value; end

Then you can do @gracz.pos = [5, 100] or @gracz.x = 5 or puts @gracz.gravity to manipulate the instance variables in a more friendly manner.

Although I said to use spaces instead of tabs, please don't mix them, because that is the worst of both worlds ;) Your editor should be able to automatically replace tabs with 2 spaces.

You might also consider putting your code up on somewhere like, which makes it easier for people to get hold of (no real need to release Windows version on a site like this, since everyone here is a Gosu developer and they don't really need an executable).

Good luck with the project and I am looking forward to being able to interact with the terrain in the game!
Parent - - By jlnr (dev) Date 2013-05-17 09:25
I would not offer the method pos, as it is tempting to write @gracz.pos.x = 5 which will not work (it only replaces the first element in a temporary array).

Not that my Ruby style is anywhere close to what's hip now - I still love then :)
Parent - - By Spooner Date 2013-05-17 09:27
Yes, I always just use x/y to avoid that problem. I was just showing how it should be done compared to how it was done. You can still do @gracz.x, @gracz.y = [3, 5] if you want to set the value with an Array.
Parent - By lol_o2 Date 2013-05-17 12:37
I'd note that you can even omit braces
@gracz.x, @gracz.y = 3, 5
Up Topic Gosu / Gosu Showcase / Blocks 2D (in development)

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill