Dear visitor, welcome to RPG Studio - Make your World real. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

Bananni

Gesperrter Nutzer

  • "Bananni" has been banned
  • "Bananni" started this thread

Motto: Belive the hype!

  • Send private message

1

Wednesday, June 16th 2010, 8:59pm

Canvas flimmert

Hi.
Ich las mein spiel innen Canvas anziegen, nur leider flimmert dieses.
Er zeigt manchmal das bild an, und manchmal löscht er einfach alles.
Leider sieht man das er alles löscht =/
Also gibt es irgendeine möglichkeit mein Canvas richtig anziegen zu lassen?
An der position von repaint kanns ja ned liegen, oder?
ich habs mal in run ohne Thread.sleep laufen lassen, flimmerte immer noch >_>
Bild
My Deviantart : )
Spoiler

StepSound Script:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#==================================
# Step Sound Script
#---------------------------------------------------
# @Autor Bananni
# @Date 07/08/2010
#==================================
class Game_Player
  # CONFIGS
  STEP_SOUND_VOLUME = 100
  STEP_SOUND_PITCH = 100
  STEP_SOUND_ARRAY=[
                    ["",0], # TERRAIN ID = 0
                    ["test.wav",10], # TERRAIN ID = 1
                    ["",0], # TERRAIN ID = 2
                    ["",0], # TERRAIN ID = 3
                    ["",0], # TERRAIN ID = 4
                    ["",0], # TERRAIN ID = 5
                    ["",0], # TERRAIN ID = 6
                    ["",0], # TERRAIN ID = 7
                    ["",0], # TERRAIN ID = 8
                    ["",0]  # TERRAIN ID = 9
                   ]
  # ENDE CONFIGS
  alias :increase_steps_banannis_shit :increase_steps
  alias :update_banannis_shit :update
  def increase_steps
    increase_steps_banannis_shit
    if @step_countdown == 0
      id = $game_map.terrain_tag(x, y)
      if STEP_SOUND_ARRAY[id][0] != ""
        Audio.se_play("Audio/SE/" + STEP_SOUND_ARRAY[id][0], STEP_SOUND_VOLUME, STEP_SOUND_PITCH)
        @step_countdown=STEP_SOUND_ARRAY[id][1]
      end
    end
  end
  def update
    update_banannis_shit
    if @step_countdown == nil
      @step_countdown=0
    end
    if @step_countdown != 0
      @step_countdown-=1
    end
  end
end


Map Roots

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#==================================
# Map Names & Map Root
#---------------------------------------------------
# @Autor Bananni
# @Date 07/08/2010
#---------------------------------------------------
# Get Map Name:
#   $game_system.map_names[any_map_id]
# Get Map Root ID:
#   $game_system.parent_map(any_map_id)
#==================================
class Game_System
  attr_reader :map_names
  alias :wtf_bananni_alias_this_game_system_init :initialize
  def initialize
    wtf_bananni_alias_this_game_system_init
    read_map_names
  end
  def parent_map id=$game_map.map_id
    while true
      par=@map_parent[id]
      break if par == 0
      id=par
    end
    return @map_names[id]
  end
  def read_map_names
    map_infos = load_data("Data/MapInfos.rxdata")
    @map_names = Array.new
    @map_parent = Array.new
    for key in map_infos.keys
      @map_names[key] = map_infos[key].name
      @map_parent[key] = map_infos[key].parent_id
    end
  end
end

highlight to read

2

Wednesday, June 16th 2010, 9:19pm

Klingt für mich nach fehlendem Doublebuffering. Ohne je mit Canvas gearbeitet zu haben(awt?oO) versuch mal

Source code

1
canvas.createBufferStrategy(2);

Bananni

Gesperrter Nutzer

  • "Bananni" has been banned
  • "Bananni" started this thread

Motto: Belive the hype!

  • Send private message

3

Friday, June 18th 2010, 7:11pm

Hab mal ne schicke strategy gebastelt.
Leider wirkt das ganze iwie ned inner paint() methode =/
Dort bekomm ich selten ein bild dann.
Ich hab es also innen 2. Thread gepackt, scheint soweit zu funktionieren.
Malt der deswegen jz über die CPU? x.x

So sieht mein code zum malen aus:

Source code

1
2
3
4
5
6
7
            Graphics2D g = (Graphics2D)strategy.getDrawGraphics();
            g.setFont(defaultFont);
            render(g);
            g.drawString("FPS: "+FPS, 10, 25);
            strategy.show();
            Toolkit.getDefaultToolkit().sync();
            g.dispose();

render(g) beinhaltet alle bilder die gerade gemalt werden sollen.

Kann ich das etwa ned so in paint packen?
Bild
My Deviantart : )
Spoiler

StepSound Script:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#==================================
# Step Sound Script
#---------------------------------------------------
# @Autor Bananni
# @Date 07/08/2010
#==================================
class Game_Player
  # CONFIGS
  STEP_SOUND_VOLUME = 100
  STEP_SOUND_PITCH = 100
  STEP_SOUND_ARRAY=[
                    ["",0], # TERRAIN ID = 0
                    ["test.wav",10], # TERRAIN ID = 1
                    ["",0], # TERRAIN ID = 2
                    ["",0], # TERRAIN ID = 3
                    ["",0], # TERRAIN ID = 4
                    ["",0], # TERRAIN ID = 5
                    ["",0], # TERRAIN ID = 6
                    ["",0], # TERRAIN ID = 7
                    ["",0], # TERRAIN ID = 8
                    ["",0]  # TERRAIN ID = 9
                   ]
  # ENDE CONFIGS
  alias :increase_steps_banannis_shit :increase_steps
  alias :update_banannis_shit :update
  def increase_steps
    increase_steps_banannis_shit
    if @step_countdown == 0
      id = $game_map.terrain_tag(x, y)
      if STEP_SOUND_ARRAY[id][0] != ""
        Audio.se_play("Audio/SE/" + STEP_SOUND_ARRAY[id][0], STEP_SOUND_VOLUME, STEP_SOUND_PITCH)
        @step_countdown=STEP_SOUND_ARRAY[id][1]
      end
    end
  end
  def update
    update_banannis_shit
    if @step_countdown == nil
      @step_countdown=0
    end
    if @step_countdown != 0
      @step_countdown-=1
    end
  end
end


Map Roots

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#==================================
# Map Names & Map Root
#---------------------------------------------------
# @Autor Bananni
# @Date 07/08/2010
#---------------------------------------------------
# Get Map Name:
#   $game_system.map_names[any_map_id]
# Get Map Root ID:
#   $game_system.parent_map(any_map_id)
#==================================
class Game_System
  attr_reader :map_names
  alias :wtf_bananni_alias_this_game_system_init :initialize
  def initialize
    wtf_bananni_alias_this_game_system_init
    read_map_names
  end
  def parent_map id=$game_map.map_id
    while true
      par=@map_parent[id]
      break if par == 0
      id=par
    end
    return @map_names[id]
  end
  def read_map_names
    map_infos = load_data("Data/MapInfos.rxdata")
    @map_names = Array.new
    @map_parent = Array.new
    for key in map_infos.keys
      @map_names[key] = map_infos[key].name
      @map_parent[key] = map_infos[key].parent_id
    end
  end
end

highlight to read

4

Saturday, June 19th 2010, 3:08pm

Mit Threads solltest du vorsichtig sein. AWT verwaltet seine eigene ThreadQueue. Ich weiß nicht, was in deinen Threads so drinne steht, aber es sollten möglichst keine Grafikoperationen sein.
Bild
RMXP Grundkurs
1 2 3
Ruby/RGSS-Kurs

Bananni

Gesperrter Nutzer

  • "Bananni" has been banned
  • "Bananni" started this thread

Motto: Belive the hype!

  • Send private message

5

Saturday, June 19th 2010, 5:59pm

Also in den einen Thread hab ich meine GameLogic, das sollte ja kein problem sein, in den 2. hab ich das malen mit meiner BufferStrategy.
also der Thread sieht so aus:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
    new Thread(this){
      @Override
      public void run(){
        while(true){
          try{
            Graphics2D g = (Graphics2D)strategy.getDrawGraphics();
            g.setFont(defaultFont);
            render(g);
            g.drawString("FPS: "+FPS, 10, 25);
            strategy.show();
//            Toolkit.getDefaultToolkit().sync();
            g.dispose();
            if(countRepaints == 999){
              System.gc();
              countRepaints = 0;
            }
            countRepaints++;
          }
          catch(Exception e){
            System.out.println(e.getMessage());
          }
        }
      }
    }.start();


vorher hab ich nur einen thread benutzt und dort GameLogic und repaint()-methode benutzt.
Als ich dann das project zu nen freund gesended hab nachdem ich die LE's hinzugefügt hab wo man die ebenen ersma auf eine reduzieren musste, hat es gelaggt, liegt es daran das ich die repaint methode im thread von meiner gameLogic benutzt hab?
Aber wie sag ich ihn denn dann das er das bild alle 16ms neu malen soll?
Malen sollte man nur in der paint()-methode ( ? echt ? ) aber repaint() darf man auch in meinen Thread aufrufen?

Oder soll ichs ganz geschickt machen und den grafiken einfach gar keinen thread geben und dann ers einmal der GameLogic einen thread verpassen und dann einfach später hinter den erstellen und starten von meinen Thread eine schleife packen wo meine repaint() methode benutzt wird?
Also dann so:

Source code

1
2
3
4
5
6
7
8
new Thread(this){
  public void run(){
    // Game Logic
  }
}
while(true){
  // Malen
}

oder so?

Source code

1
2
3
4
5
6
new Thread(this){
  public void run(){
    repaint();
    // + Game Logic
  }
}

Aber Audio-methoden dürfen ruhig in einen Thread oder?
Bild
My Deviantart : )
Spoiler

StepSound Script:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#==================================
# Step Sound Script
#---------------------------------------------------
# @Autor Bananni
# @Date 07/08/2010
#==================================
class Game_Player
  # CONFIGS
  STEP_SOUND_VOLUME = 100
  STEP_SOUND_PITCH = 100
  STEP_SOUND_ARRAY=[
                    ["",0], # TERRAIN ID = 0
                    ["test.wav",10], # TERRAIN ID = 1
                    ["",0], # TERRAIN ID = 2
                    ["",0], # TERRAIN ID = 3
                    ["",0], # TERRAIN ID = 4
                    ["",0], # TERRAIN ID = 5
                    ["",0], # TERRAIN ID = 6
                    ["",0], # TERRAIN ID = 7
                    ["",0], # TERRAIN ID = 8
                    ["",0]  # TERRAIN ID = 9
                   ]
  # ENDE CONFIGS
  alias :increase_steps_banannis_shit :increase_steps
  alias :update_banannis_shit :update
  def increase_steps
    increase_steps_banannis_shit
    if @step_countdown == 0
      id = $game_map.terrain_tag(x, y)
      if STEP_SOUND_ARRAY[id][0] != ""
        Audio.se_play("Audio/SE/" + STEP_SOUND_ARRAY[id][0], STEP_SOUND_VOLUME, STEP_SOUND_PITCH)
        @step_countdown=STEP_SOUND_ARRAY[id][1]
      end
    end
  end
  def update
    update_banannis_shit
    if @step_countdown == nil
      @step_countdown=0
    end
    if @step_countdown != 0
      @step_countdown-=1
    end
  end
end


Map Roots

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#==================================
# Map Names & Map Root
#---------------------------------------------------
# @Autor Bananni
# @Date 07/08/2010
#---------------------------------------------------
# Get Map Name:
#   $game_system.map_names[any_map_id]
# Get Map Root ID:
#   $game_system.parent_map(any_map_id)
#==================================
class Game_System
  attr_reader :map_names
  alias :wtf_bananni_alias_this_game_system_init :initialize
  def initialize
    wtf_bananni_alias_this_game_system_init
    read_map_names
  end
  def parent_map id=$game_map.map_id
    while true
      par=@map_parent[id]
      break if par == 0
      id=par
    end
    return @map_names[id]
  end
  def read_map_names
    map_infos = load_data("Data/MapInfos.rxdata")
    @map_names = Array.new
    @map_parent = Array.new
    for key in map_infos.keys
      @map_names[key] = map_infos[key].name
      @map_parent[key] = map_infos[key].parent_id
    end
  end
end

highlight to read

6

Saturday, June 19th 2010, 6:41pm

Also eigentlich sollte der Code zum Zeichnen in die paint-Methode rein. Zum Updaten nutzt du die repaint-Methode. Das eigentliche Zeichnen wird dann in einen eigenen Thread ausgeführt, eigentlich dürfte es nicht laggen.
Bild
RMXP Grundkurs
1 2 3
Ruby/RGSS-Kurs

Bananni

Gesperrter Nutzer

  • "Bananni" has been banned
  • "Bananni" started this thread

Motto: Belive the hype!

  • Send private message

7

Saturday, June 19th 2010, 7:13pm

so hab ichs gemacht, und siehe da es klappt xD
war n kleiner fehler drinne, der is raus und jz lags auch ned mehr aufn pc von meinen freund =P
ty
Bild
My Deviantart : )
Spoiler

StepSound Script:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#==================================
# Step Sound Script
#---------------------------------------------------
# @Autor Bananni
# @Date 07/08/2010
#==================================
class Game_Player
  # CONFIGS
  STEP_SOUND_VOLUME = 100
  STEP_SOUND_PITCH = 100
  STEP_SOUND_ARRAY=[
                    ["",0], # TERRAIN ID = 0
                    ["test.wav",10], # TERRAIN ID = 1
                    ["",0], # TERRAIN ID = 2
                    ["",0], # TERRAIN ID = 3
                    ["",0], # TERRAIN ID = 4
                    ["",0], # TERRAIN ID = 5
                    ["",0], # TERRAIN ID = 6
                    ["",0], # TERRAIN ID = 7
                    ["",0], # TERRAIN ID = 8
                    ["",0]  # TERRAIN ID = 9
                   ]
  # ENDE CONFIGS
  alias :increase_steps_banannis_shit :increase_steps
  alias :update_banannis_shit :update
  def increase_steps
    increase_steps_banannis_shit
    if @step_countdown == 0
      id = $game_map.terrain_tag(x, y)
      if STEP_SOUND_ARRAY[id][0] != ""
        Audio.se_play("Audio/SE/" + STEP_SOUND_ARRAY[id][0], STEP_SOUND_VOLUME, STEP_SOUND_PITCH)
        @step_countdown=STEP_SOUND_ARRAY[id][1]
      end
    end
  end
  def update
    update_banannis_shit
    if @step_countdown == nil
      @step_countdown=0
    end
    if @step_countdown != 0
      @step_countdown-=1
    end
  end
end


Map Roots

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#==================================
# Map Names & Map Root
#---------------------------------------------------
# @Autor Bananni
# @Date 07/08/2010
#---------------------------------------------------
# Get Map Name:
#   $game_system.map_names[any_map_id]
# Get Map Root ID:
#   $game_system.parent_map(any_map_id)
#==================================
class Game_System
  attr_reader :map_names
  alias :wtf_bananni_alias_this_game_system_init :initialize
  def initialize
    wtf_bananni_alias_this_game_system_init
    read_map_names
  end
  def parent_map id=$game_map.map_id
    while true
      par=@map_parent[id]
      break if par == 0
      id=par
    end
    return @map_names[id]
  end
  def read_map_names
    map_infos = load_data("Data/MapInfos.rxdata")
    @map_names = Array.new
    @map_parent = Array.new
    for key in map_infos.keys
      @map_names[key] = map_infos[key].name
      @map_parent[key] = map_infos[key].parent_id
    end
  end
end

highlight to read

8

Tuesday, June 22nd 2010, 11:48am

Ach Ja, kleiner Tipp meinerseits:

Wenn ihr JPanel verwendet braucht ihr nur:
setDoubleBuffered(true) machen, dann übernimmt Java das Double Buffering

Social bookmarks