Gut ja, dann liegt eindeutig hier der Fehler... gleich der letzte Befehl der Methode. Code: def initialize @figure_names = ["Spinne1.png", "Spinne2.png", "Spinne3.png", "Spinne4.png", "Spinne5.png", "Spinne6.png", "Spinne7.png", "Spinne8.png", "Spinne9.png", "Spinne10.png", "Spinne11.png", "Spinne12.png", "Spinne13.png", "Spinne14.png", "Spinne15.png", "Spinne16.png"] @positions = [ 0, 0, 136, 0, 272, 0, 408, 0, # 0, 104, 136, 104, 272, 104, 408, 104, # 0, 208, 136, 208, 272, 208, 408, 208, # 0, 312, 136, 312, 272, 312, 408, 312 ] # number of cards horizontal @max_number_of_cols = 4 # size of cards @card_width = 64 @card_height = 64 # distance between cards @margin = 12 p @positions @memory = Game_Memory.new end Habe ich wohl etwas mal wieder falsch verstanden... Ansonsten noch mal der ganze Code. Code: class Game_Memory # hier kommen alle Attribute rein die dein Spiel so hat # filenames of the pictures of your cards attr_accessor :figure_names def initialize @figure_names = ["Spinne1.png", "Spinne2.png", "Spinne3.png", "Spinne4.png", "Spinne5.png", "Spinne6.png", "Spinne7.png", "Spinne8.png", "Spinne9.png", "Spinne10.png", "Spinne11.png", "Spinne12.png", "Spinne13.png", "Spinne14.png", "Spinne15.png", "Spinne16.png"] @positions = [ 0, 0, 136, 0, 272, 0, 408, 0, # 0, 104, 136, 104, 272, 104, 408, 104, # 0, 208, 136, 208, 272, 208, 408, 208, # 0, 312, 136, 312, 272, 312, 408, 312 ] # number of cards horizontal @max_number_of_cols = 4 # size of cards @card_width = 64 @card_height = 64 # distance between cards @margin = 12 p @positions @memory = Game_Memory.new end # returns x, y coordinates as well as the image name of # the card with the given index def get_card index [card_x(index), card_y(index), card_image(index)] end # return all cards def get_cards # create a new array with elements # for all indizes from 0 upto @positions.size (0...@positions.size).map do |index| # each element contains the result value of # get_card get_card index end end # x coordinate for a given card index def card_x index col_num = index % @max_number_of_cols col_num * (@card_width + @margin) end # y coordinate for a given card index def card_y index row_num = index / @max_number_of_cols row_num * (@card_height+@margin) end # filename of card image def card_image index @figure_names[@positions[index]] end # number of different figures/cards def number_of_pictures @figure_names.size end # add 2 cards for each figure into the field # shuffle the positions of all cards def shuffle_cards @positions.clear # this loop is invoked as often as the number # of different cards number_of_pictures.times do |picture_id| # for each invocation, two cards are added # into the array @positions << picture_id << picture_id end # shuffle the array at the end @positions.shuffle! end end class Game_System # füge Memory als Attribut hinzu attr_accessor :memory end # Erbebt von Scene_Base class Scene_Memory < Scene_Base #class << self #------------------------------------------------------------------------------- # Überschreibt start von Scene_Base #------------------------------------------------------------------------------- def initialize_graphics # for each card in the game @card_sprites = $game_system.memory.get_cards.map do |x, y, image| # create a new sprite sprite = Sprite.new # set its graphic and coordinates sprite.bitmap = Cache.picture(image) sprite.x, sprite.y = x, y # and "return" the sprite into the array sprite end end def update_graphics # update attributes of all sprites @card_sprites.each_with_index do |sprite, index| x, y, image = $game_system.memory.get_card(index) sprite.bitmap = Cache.picture(image) sprite.x, sprite.y = x,y end end def dispose_graphics @card_sprites.each do |sprite| sprite.dispose end end #------------------------------------------------------------------------------- # überschreibt terminate Scene_Base #------------------------------------------------------------------------------- def terminate super dispose_graphics end #------------------------------------------------------------------------------- # überschreibt update Scene_Base #------------------------------------------------------------------------------- def update super update_graphics end def start #(start) super initialize_graphics update end end #end
def initialize @figure_names = ["Spinne1.png", "Spinne2.png", "Spinne3.png", "Spinne4.png", "Spinne5.png", "Spinne6.png", "Spinne7.png", "Spinne8.png", "Spinne9.png", "Spinne10.png", "Spinne11.png", "Spinne12.png", "Spinne13.png", "Spinne14.png", "Spinne15.png", "Spinne16.png"] @positions = [ 0, 0, 136, 0, 272, 0, 408, 0, # 0, 104, 136, 104, 272, 104, 408, 104, # 0, 208, 136, 208, 272, 208, 408, 208, # 0, 312, 136, 312, 272, 312, 408, 312 ] # number of cards horizontal @max_number_of_cols = 4 # size of cards @card_width = 64 @card_height = 64 # distance between cards @margin = 12 p @positions @memory = Game_Memory.new end
class Game_Memory # hier kommen alle Attribute rein die dein Spiel so hat # filenames of the pictures of your cards attr_accessor :figure_names def initialize @figure_names = ["Spinne1.png", "Spinne2.png", "Spinne3.png", "Spinne4.png", "Spinne5.png", "Spinne6.png", "Spinne7.png", "Spinne8.png", "Spinne9.png", "Spinne10.png", "Spinne11.png", "Spinne12.png", "Spinne13.png", "Spinne14.png", "Spinne15.png", "Spinne16.png"] @positions = [ 0, 0, 136, 0, 272, 0, 408, 0, # 0, 104, 136, 104, 272, 104, 408, 104, # 0, 208, 136, 208, 272, 208, 408, 208, # 0, 312, 136, 312, 272, 312, 408, 312 ] # number of cards horizontal @max_number_of_cols = 4 # size of cards @card_width = 64 @card_height = 64 # distance between cards @margin = 12 p @positions @memory = Game_Memory.new end # returns x, y coordinates as well as the image name of # the card with the given index def get_card index [card_x(index), card_y(index), card_image(index)] end # return all cards def get_cards # create a new array with elements # for all indizes from 0 upto @positions.size (0...@positions.size).map do |index| # each element contains the result value of # get_card get_card index end end # x coordinate for a given card index def card_x index col_num = index % @max_number_of_cols col_num * (@card_width + @margin) end # y coordinate for a given card index def card_y index row_num = index / @max_number_of_cols row_num * (@card_height+@margin) end # filename of card image def card_image index @figure_names[@positions[index]] end # number of different figures/cards def number_of_pictures @figure_names.size end # add 2 cards for each figure into the field # shuffle the positions of all cards def shuffle_cards @positions.clear # this loop is invoked as often as the number # of different cards number_of_pictures.times do |picture_id| # for each invocation, two cards are added # into the array @positions << picture_id << picture_id end # shuffle the array at the end @positions.shuffle! end end class Game_System # füge Memory als Attribut hinzu attr_accessor :memory end # Erbebt von Scene_Base class Scene_Memory < Scene_Base #class << self #------------------------------------------------------------------------------- # Überschreibt start von Scene_Base #------------------------------------------------------------------------------- def initialize_graphics # for each card in the game @card_sprites = $game_system.memory.get_cards.map do |x, y, image| # create a new sprite sprite = Sprite.new # set its graphic and coordinates sprite.bitmap = Cache.picture(image) sprite.x, sprite.y = x, y # and "return" the sprite into the array sprite end end def update_graphics # update attributes of all sprites @card_sprites.each_with_index do |sprite, index| x, y, image = $game_system.memory.get_card(index) sprite.bitmap = Cache.picture(image) sprite.x, sprite.y = x,y end end def dispose_graphics @card_sprites.each do |sprite| sprite.dispose end end #------------------------------------------------------------------------------- # überschreibt terminate Scene_Base #------------------------------------------------------------------------------- def terminate super dispose_graphics end #------------------------------------------------------------------------------- # überschreibt update Scene_Base #------------------------------------------------------------------------------- def update super update_graphics end def start #(start) super initialize_graphics update end end #end
Stichwortwolke anzeigen
Foren-Regeln