Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("LWLGL")
- bgs = LWLGL.initBackgrounds()
- w, h = LWLGL.w, LWLGL.h
- timer = os.startTimer(0.1)
- bgs:add({name="t1",file="testimg",bc="blue",x=1,y=1,update=function(self)
- bgs:draw("t1",self.x,self.y)
- end})
- bgs:add({name="t2",file="clouds",bc="blue",x=1,y=1,update=function(self)
- bgs:draw("t2",self.x,self.y)
- if(self.x >= w+2)then
- self.x = -w
- change = math.max(math.random(1,2))
- if(change == 1)then
- self.file = "sky2"
- else
- self.file = "clouds"
- end
- end
- self.x = self.x + 2
- end})
- bgs:add({name="t3",file="grass",bc="green",x=1,y=5,xdir=1,update=function(self)
- bgs:draw("t3",self.x,self.y)
- if(self.xdir == 1)then
- self.x=self.x+1
- if(self.x >= 5)then self.xdir = 2 end
- elseif(self.xdir == 2)then self.x=self.x-1
- if(self.x <= 0)then
- self.xdir = 1
- end
- end
- end})
- bgs:add({name="t4",file="clouds",bc="blue",x=-w,y=1,update=function(self)
- bgs:draw("t4",self.x,self.y)
- if(self.x >= w+2)then
- self.x = -w
- change = math.max(math.random(1,2))
- if(change == 1)then
- self.file = "sky2"
- else
- self.file = "clouds"
- end
- end
- self.x = self.x + 1
- end})
- bgs:add({name="t5",file="clouds",bc="blue",x=w,y=1,update=function(self)
- bgs:draw("t5",self.x,self.y)
- if(self.x >= w+2)then
- self.x = -w
- change = math.max(math.random(1,2))
- if(change == 1)then
- self.file = "sky2"
- else
- self.file = "clouds"
- end
- end
- self.x = self.x + 4
- end})
- map = LWLGL.createGame()
- map = LWLGL.createPlayer(map,5,5)
- bgs:update()
- LWLGL.sbc(colors.black)
- term.clear()
- while true do
- term.current().setVisible(false)
- LWLGL.sbc(colors.lightBlue)
- local evs = LWLGL.catchEvents()
- if(evs[1] == "timer")then
- term.clear()
- bgs:update()
- map.player:draw()
- timer = os.startTimer(0.1)
- end
- term.current().setVisible(true)
- map:update(evs)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement