Forum
Ok, Ok, Ok!, now i understood!!!,
now work!!, the problem was very simple!,
i try with:
$tile[0].draw(@x, @y, 0)
and now works!!
Thanks for all the help!!
but i want to make:
@map[2][0].setId(block[:stone])
like that!.
i understood the first part...
like that:
require 'gosu'
$tile = Gosu::Image.load_tiles("res/tile.png", 16, 16)
class GameWindow < Gosu::Window
def initialize()
super(480, 480, false)
self.caption = "Pix2D"
end
def update()
#$level.tick()
end
def draw()
#$level.render()
$tile[0].draw(0,0,0)
end
def needs_cursor?
true
end
end
GameWindow.new.show
you can make an example with Code, a simple game with a tile?,
i'm from brazil, and i don't speak and read english good...
you can make a simple example? please...
i don't understood...
ok, now works, but is not working corectly!, the window show the full tile image...
Nope!, i have changed but the Terminal say the same error...
Ok!, now have a new Problem!...
code:
require 'gosu'
$size = 16
$tile = Gosu::Image.new("res/tile.png", :tileable => true)
$ids = {
:air => [0, 0],
:dirt => [4, 0]
}
$w = 30
$h = $w
$level = Level.new(30, 30)
class Block
def initialize(id, x, y)
@id = id
@x = x
@y = y
end
def getId()
return @id
end
def setId(id)
@id = id
end
def tick()
end
def render()
$tile.draw((@id[0]*$size), (@id[1]*$size), 0)
end
end
def Level
def initialize(w, h)
@w = w
@h = h
@map = []
initLevel()
end
def initLevel()
@w.times() do |x|
@map[x] = []
@h.times() do |y|
@map[x][y] = Block.new($ids[:air], x*$size, y*$size)
end
end
end
def tick()
end
def render()
@w.times() do |x|
@h.times() do |y|
@map[x][y].render()
end
end
end
end
class GameWindow < Gosu::Window
def initialize()
super(480, 480, false)
self.caption = "Pix2D"
end
def update()
$level.tick()
end
def draw()
$level.render()
end
def needs_cursor?
true
end
end
def fillRect(x, y, width, height, t, color)
draw_quad(x+t-width, y+t-height, color, x+t+width, y+t-height, color, x+t-width, y+t+height, color, x+t+width, y+t+height, color, 0)
end
GameWindow.new.show
ERROR:
main.rb:15:in `<main>': uninitialized constant Level (NameError)
but i want to make my game with a tileset,
is just 1 Image, with all the blocks,
and i just add a block with:
$ids = {
:air => [0, 0]
}
understood?
Hello? someone can help-me?
Hello everyone!,
i want to make a 2d minecraft-like plataformer game,
i make this game with Quby, an Ruby-Like programing language, but
i like too much Ruby, and a want to create my game with gosu,
but my problem is:
i want to make a tile image with all Minecraft blocks,
and i use a hash for add the block in the game
like that:
$tile = {
:air => [0,0]
}
and the air blocks was in the firt tile
of the Tileset!
but the gosu draws is:
image.draw(x, y)
i need this one:
drawImage( image, srcX, srcY, srcWidth, srcHeight, x, y, width, height, isCentred=false )
this class i want to draw:
class Block
def new(id, x, y)
@size = 16
@id = id
@x = x
@y = y
@w = @size
@h = @w
end
def getId()
return @id
end
def setId(id)
@id = id
end
def getX()
return @x
end
def getY()
return @y
end
def render()
if @id != $blocks[:air]
drawImage( $tile, @id[0]*@size, @id[1]*@size, @size, @size, @x, @y, @w, @h )
end
end
end
help me Please!,
thanks.
Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill