jugador = { x = 0, y = 0, vx = 1, vy = 1, color = COLOR_YELLOW, color_fondo = COLOR_RED, sprite = chr(250), comptador = 0, actualitza = function(self) self.comptador = self.comptador + 1 self:anima() self:mou() self:comprova_bordes() end, mou = function(self) if self.comptador % 30 == 0 then self.x = self.x + self.vx self.y = self.y + self.vy end end, comprova_bordes = function (self) if self.x > pantalla_borde_dret then self.vx = self.vx * -1 self.x = pantalla_borde_dret end if self.x < pantalla_borde_esquerre then self.vx = self.vx * -1 self.x = pantalla_borde_esquerre end if self.y > pantalla_borde_baix then self.vy = self.vy * -1 self.y = pantalla_borde_baix end if self.y < pantalla_borde_dalt then self.vy = self.vy * -1 self.y = pantalla_borde_dalt end end, dibuixa = function(self) paper(self.color_fondo) ink(self.color) print(self.sprite, self.x, self.y) end, anima = function(self) if self.comptador % 60 < 30 then self.sprite = chr(250) else self.sprite = chr(251) end end } pantalla_borde_dalt = 0 pantalla_borde_baix = 29 pantalla_borde_esquerre = 0 pantalla_borde_dret = 39 function init() mode(1) paper(COLOR_BLACK) ink(COLOR_RED) end function update() jugador:actualitza() paper(COLOR_RED) cls() jugador:dibuixa() end