Probleme Codage "lua"


echecoroi
 Share

Messages recommandés

salut a tous.

je vien de finir (o moins pour le tester) un code mais je m appercois de plusieurs erreurs........vu que j apprends le language lua depuis 2 mois , il est normal que j en fasse :) .

premiere erreur...: loop in gettable??? ......a la ligne 174

---------------**collision**---------

while true do

function collisionCheck(test)

:angry: la ligne en question...if (player.x + playerWidth > test.x) and (player.x < test.x + test.width) and

(player.y + playerHeight > test.y) and (player.y < test.y + test.height) then

player.x = oldx

player.y = oldy

end

end

puis-je faire un copier coller de mon code pour vous le montrer afin d avoir reponse a mes questions...

merci d'avance pour votre aide a+

Lien vers le commentaire
Partager sur d'autres sites

fazerick ta répondu ICI

merci d avoir repondu.....voici mon code car je pense qu il y a pas mal de boulette......

--images de fonds

background2 = Image.load("background2.png")

background = Image.load("background.png")

background1 = Image.load("background1.png")

--------Right sprites---------

player1 = Image.load("sprites/right1.png")

player2 = Image.load("sprites/right2.png")

player3 = Image.load("sprites/right3.png")

player35 = Image.load("sprites/right4.png")

---------left sprites--------

player4 = Image.load("sprites/left1.png")

player5 = Image.load("sprites/left2.png")

player6 = Image.load("sprites/left3.png")

player65 = Image.load("sprites/left4.png")

-------Up sprites-------------

player7 = Image.load("sprites/up1.png")

player8 = Image.load("sprites/up2.png")

player9 = Image.load("sprites/up3.png")

player95 = Image.load("sprites/up4.png")

-------Down sprites------------

player10 = Image.load("sprites/down1.png")

player11 = Image.load("sprites/down2.png")

player12 = Image.load("sprites/down3.png")

player125 = Image.load("sprites/down4.png")

-----------**Walls**---------

wall1 = Image.createEmpty(14,135) -----Top Left Hand Wall

wall2 = Image.createEmpty(14,100) -----Bottom Left Hand Wall

--chargement de sons

music = Sound.load("sik/music.wav", true)

local sound = music

voice = sound:play()

--position de depard

player = {}

player.x = 30

player.y = 210

playerHeight = 20

playerWidth = 25

player.img = nright

--valeur du temps

counter = Timer.new()

counter:start()

oldTime = counter:time()

Timer = 0

--chargement des mouvements

function moveRight() ------mouvements de droite

Timer = Timer + 1

if Timer>= 25 or Timer<=0 then

Timer = 0

end

if Timer==5 then

player.img = player1

end

if Timer==10 then

player.img = player2

end

if Timer==15 then

player.img = player3

counter:reset()

end

if Timer==20 then

player.img = player35

counter:reset()

end

end

function moveLeft() ----mouvements de gauche

Timer = Timer + 1

if Timer>= 25 or Timer<=0 then

Timer = 0

end

if Timer==5 then

player.img = player4

end

if Timer==10 then

player.img = player5

end

if Timer==15 then

player.img = player6

counter:reset()

end

if Timer==20 then

player.img = player65

counter:reset()

end

end

function moveUp() ------Up Animation

Timer = Timer + 1

if Timer>= 25 or Timer <= 0 then

Timer = 0

end

if Timer==5 then

player.img = player7

end

if Timer==10 then

player.img = player8

end

if Timer==15 then

player.img = player9

counter:reset()

end

if Timer==20 then

player.img = player95

counter:reset()

end

end

function moveDown() ------Down Animation

Timer = Timer + 1

if Timer>= 25 or Timer<=0 then

Timer = 0

end

if Timer==5 then

player.img = player10

end

if Timer==10 then

player.img = player11

end

if Timer==15 then

player.img = player12

counter:reset()

end

if Timer==20 then

player.img = player125

counter:reset()

end

end

---------------**collision**---------

function collisionCheck(test)

if (player.x + player.Width > test.x) and (player.x < test.x + test.width) and

(player.y + player.Height > test.y) and (player.y < test.y + test.height) then

player.x = oldx

player.y = oldy

end

end

-------**position de joueurs au début de chaque boucle**----

oldx = player.x

oldy = player.y

screen:clear()

---------**init gamepad**-------

pad = Controls.read()

---------**player mouvement**---

if pad:right() then -----Right Mouvement

moveRight()

player.x = player.x + 2

end

if pad:left() then -----Left Mouvement

moveLeft()

player.x = player.x - 2

end

if pad:up() then -----Up Mouvement

moveUp()

player.y = player.y - 2

end

if pad:down() then -----Down Mouvement

moveDown()

player.y = player.y + 2

end

--autres

if pad:select() then screen:save("screenshot.png") end --Screenshot

screen:blit(0, 0, background2)

playertext()

-------**end loop**-----

screen.waitVblankStart()

end

Lien vers le commentaire
Partager sur d'autres sites

Créer un compte ou se connecter pour commenter

Vous devez être membre afin de pouvoir déposer un commentaire

Créer un compte

Créez un compte sur notre communauté. C’est facile !

Créer un nouveau compte

Se connecter

Vous avez déjà un compte ? Connectez-vous ici.

Connectez-vous maintenant
 Share