[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Sprites... I suck at them....(rubygame

Mohammad ---

10/19/2006 2:16:00 AM

okay here is my little sprite file with rubygame


require "rubygame"
$stdout.sync = true
Rubygame.init()


class Chr
include Rubygame::Sprites::Sprite
@@chrforward = Rubygame::Image.load("forward.png")
@@chrleft = Rubygame::Image.load("left.png")
@@chrright = Rubygame::Image.load("right.png")
@@chrbackword = Rubygame::Image.load("backwords.png")
@@chrforward.set_colorkey(@@chrforward.get_at([0,0]))
@@chrleft.set_colorkey(@@chrleft.get_at([0,0]))
@@chrright.set_colorkey(@@chrright.get_at([0,0]))
@@chrbackword.set_colorkey(@@chrbackword.get_at([0,0]))

def load_image_for(dir)
if dir == "back" || dir == "backword"
return @@chrbackword
elsif dir == "left"
return @@chrleft
elsif dir == "right"
return @@chrright
elsif dir == "forward" || dir == "up"
return @@chrforward
end
end

def initalize(x,y,starter="forward")
@image = load_image_for starter
@rect = Rubygame::Rect.new(x,y,*@@chrforward.size)
end

def update_image(dir)
load_image_for dir
end

def update(dir)
self.update_image(dir)
@rect = @image.size
end

end

class MyNPC
include Rubygame::Sprites::Sprite
@@npcforward = Rubygame::Image.load("npcforward.png")
@@npcleft = Rubygame::Image.load("npcleft.png")
@@npcright = Rubygame::Image.load("npcright.png")
@@npcbackword = Rubygame::Image.load("npcbackwords.png")
@@npcforward.set_colorkey(@@npcforward.get_at([0,0]))
@@npcleft.set_colorkey(@@npcleft.get_at([0,0]))
@@npcright.set_colorkey(@@npcright.get_at([0,0]))
@@npcbackword.set_colorkey(@@npcbackword.get_at([0,0]))

def load_image_for(dir)
if dir == "back" || dir == "backword"
return @@npcbackword
elsif dir == "left"
return @@npcleft
elsif dir == "right"
return @@npcright
elsif dir == "forward" || dir == "up"
return @@npcforward
end
end

def initalize(x,y,starter="forward")
@image = load_image_for starter
@rect = Rubygame::Rect.new(x,y,*@@npcforward.size)
end

def update_image(dir)
load_image_for dir
end

def update(dir)
self.update_image(dir)
@rect = @image.size
end

end

class ChrGroup < Rubygame::Sprites::Group
include Rubygame::Sprites::UpdateGroup
end

screen = Rubygame::Screen.set_mode([320,240])
screen.set_caption("Sprite test","SPRITE TEST")
background = Rubygame::Surface.new(screen.size)


mainchr = Chr.new
npc = MyNPC.new
mainchr.initalize(0,0)
npc.initalize(50,50)

chrs = ChrGroup.new
chrs.push(mainchr,npc)
chrs.draw(screen)


catch(:rubygame_quit) do
loop do
chrs.undraw(screen,background)
chrs.update("left")
puts "left"
sleep 2
chrs.update("up")
puts "up"
sleep 2
chrs.update("right")
puts "right"
sleep 2
chrs.update("down")
puts "down"
sleep 2
chrs.draw(screen)
screen.update()
end
end


Very messey I know! Well two problems with it...
one:
chrs.update doesn't seem to be drawing them
two:
one the secound loop it crashes because then it dosn't like
chrs.undraw

is there a better placce for me to post these also does anyone know a
good tut. on rubygame?

--
Posted via http://www.ruby-....

2 Answers

Bob

9/14/2010 5:36:00 PM

0

"JayPee Vee" <jaypee1965@gmail.com> wrote in message
news:e8b65075-62ca-41b8-8097-1bdfd04410bd@h25g2000vba.googlegroups.com...
On 14 Sep., 17:36, President Soetoro
<osama.obabma.by.anyn...@gmail.com> wrote:
> On Sep 14, 8:23 am, "Bob" <dalnet...@att.net> wrote:
>
> > The White House fights an effort to ease a burden on small business.
>
> > Mr. President, why do you support small business in your speeches and
> > hurt
> > them with your policies? You are becoming known as the "All Fluff, No
> > Substance" president.
>
> Why would you think this administration, or any ?berlist socialist
> administration would ever give a shit about small business, or
> business in general!?!

Like someone who takes "President Soetero" as an alias will have
something relevant or intelligent to say...
It's true that he is a untermoron fascist though....
********************************************
JayPee Vee: Dishonest poster; changes subject of threads.


JayPee Vee

9/14/2010 8:59:00 PM

0

On 14 Sep., 19:35, "Bob" <dalnet...@att.net> wrote:
> "JayPee Vee" <jaypee1...@gmail.com> wrote in message
>
> news:e8b65075-62ca-41b8-8097-1bdfd04410bd@h25g2000vba.googlegroups.com...
> On 14 Sep., 17:36, President Soetoro
>
> <osama.obabma.by.anyn...@gmail.com> wrote:
> > On Sep 14, 8:23 am, "Bob" <dalnet...@att.net> wrote:
>
> > > The White House fights an effort to ease a burden on small business.
>
> > > Mr. President, why do you support small business in your speeches and
> > > hurt
> > > them with your policies? You are becoming known as the "All Fluff, No
> > > Substance" president.
>
> > Why would you think this administration, or any überlist socialist
> > administration would ever give a shit about small business, or
> > business in general!?!
>
> Like someone who takes "President Soetero" as an alias will have
> something relevant or intelligent to say...
> It's true that he is a untermoron fascist though....
> ********************************************
> JayPee Vee: Dishonest poster; changes subject of threads.

And here we go again...

boycott boob: republican whore, does it without vaseline, liar,
hypocrite and vain.