Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local w,a,s,d,space = false,false,false,false,false
- local x,y = 26,17
- local cooldown = 10
- function Paint()
- term.setBackgroundColor(colors.black)
- term.clear()
- -- Player
- paintutils.drawPixel(x,y,colors.green)
- paintutils.drawLine(x-1,y+1,x+1,y+1,colors.green)
- -- Enemies
- end
- function Movement()
- if (w==true) then y=y-1 end
- if (a==true) then x=x-1 end
- if (s==true) then y=y+1 end
- if (d==true) then x=x+1 end
- --Shooting ¿How tho...?
- cooldown=cooldown-1
- if (space==true and cooldown<=0) then
- print("Pew Pew Im a bullet >:)")
- cooldown=10
- end
- --Correction
- if (x>=50) then x=49 end
- if (x<=2) then x=3 end
- if (y>=18) then y=17 end
- if (y<=1) then y=2 end
- end
- -- Main --
- while(true) do
- parallel.waitForAny(function()
- Movement()
- Paint()
- sleep(0.2)
- end,
- function()
- local e,k = os.pullEvent("key")
- if (k == keys.space) then space=true
- elseif (k == keys.w) then w=true
- elseif (k == keys.a) then a=true
- elseif (k == keys.s) then s=true
- elseif (k == keys.d) then d=true
- end
- end,
- function()
- local e,k = os.pullEvent("key_up")
- if (k == keys.space) then space=false
- elseif (k == keys.w) then w=false
- elseif (k == keys.a) then a=false
- elseif (k == keys.s) then s=false
- elseif (k == keys.d) then d=false
- end
- end
- )
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement