Why is the code printing the character in the same positions, even though I have conditioned to move the position? I want to print the input like chat

Viewed 37

Note: self.bitmap.draw_text(0,0,220+p,20, 'A', 1) where 220+p is the coordinates x, and 20 is y of screen

Why is the code showing the character in the same positions, even though I have conditioned to move the position? I tried to do it in another way and the 'A' always came ahead regardless of whether I added p+30. I want use it to create a chatbox with RGSS (Rpg Maker XP).

The result of this code works, I wrote this code, but it works not as intended. It Show the button that I pressed, but when I press A and B, the A is always in the first coordinates then came B: "AB" is showed but never "BA" even if I pressed B first.

class Sprite_Texto < Sprite
def initialize



super(nil)
self.bitmap = Bitmap.new(150,20)
self.ox = 100
self.z = 999
self.bitmap.font.size = 14
self.bitmap.font.bold = true #negrito
self.bitmap.font.name = "Verdana"
end
def escrever
 self.bitmap = Bitmap.new(700,700)
    p = 0
    teste = Win32API.new("user32","GetAsyncKeyState",['i'],'i').call(0x10)
    teste2 = Win32API.new("user32","GetAsyncKeyState",['i'],'i').call(0x41)
    teste3 = Win32API.new("user32","GetAsyncKeyState",['i'],'i').call(0x42)
    if teste2 > 0
    p = p+30
    self.bitmap.draw_text(0,0,220+p,20, 'A', 1)
    else
      if teste3 > 0
        p = p+30
        self.bitmap.draw_text(0,0,220+p,20, 'B', 1)
      end
      end
end
end
0 Answers
Related