Всем добрый день.
Хочу показать вам скрипт на Multiple Bullets.
green=Color.new(0,255,0)
white = Color.new(255,255,255)
blue=Color.new(0,0,255)
bullet = Image.createEmpty(4,4)
bullet:clear(green)
player = Image.createEmpty(32,32)
player:clear(white)
oldpad = Controls.read()
currentBullet = 0
direction = "right"
Player = {}
Player[1] = { x = 30, y = 100 }
BulletInfo = {}
for a = 1,5 do
BulletInfo[a] = { pic = bullet , firing = false, direction = "right", x = Player[1].x + 32,
y = Player[1].y + 16 }
end
function bulletSetup()
if currentBullet < 5 then
currentBullet = currentBullet + 1
else
currentBullet = 1
end
if direction == "left" then
BulletInfo[currentBullet].x = Player[1].x
BulletInfo[currentBullet].y = Player[1].y + 16
end
if direction == "right" then
BulletInfo[currentBullet].x = Player[1].x + 32
BulletInfo[currentBullet].y = Player[1].y + 16
end
if direction == "up" then
BulletInfo[currentBullet].x = Player[1].x + 16
BulletInfo[currentBullet].y = Player[1].y
end
if direction == "down" then
BulletInfo[currentBullet].x = Player[1].x + 16
BulletInfo[currentBullet].y = Player[1].y + 32
end
BulletInfo[currentBullet].direction = direction
BulletInfo[currentBullet].firing = true
end
function bulletFire()
for i = 1,5 do
if BulletInfo[i].firing == true then
if BulletInfo[i].direction == "right" then BulletInfo[i].x = BulletInfo[i].x + 10 end
if BulletInfo[i].direction == "left" then BulletInfo[i].x = BulletInfo[i].x - 10 end
if BulletInfo[i].direction == "up" then BulletInfo[i].y = BulletInfo[i].y - 10 end
if BulletInfo[i].direction == "down" then BulletInfo[i].y = BulletInfo[i].y + 10 end
screen:blit(BulletInfo[i].x,BulletInfo[i].y,BulletInfo[i].pic)
end
if BulletInfo[i].x 480 or BulletInfo[i].y 272 then
BulletInfo[i].firing = false
end
end
end
function movePlayer()
pad = Controls.read()
if pad:left() then
Player[1].x = Player[1].x - 1
direction = "left"
end
if pad:right() then
Player[1].x = Player[1].x + 1
direction = "right"
end
if pad:up() then
Player[1].y = Player[1].y - 1
direction = "up"
end
if pad:down() then
Player[1].y = Player[1].y + 1
direction = "down"
end
end
while true do
pad = Controls.read()
screen:clear(blue)
screen:blit(Player[1].x, Player[1].y, player)
if pad:cross() and oldpad:cross() ~= pad:cross() then
bulletSetup()
end
movePlayer()
bulletFire()
screen.waitVblankStart()
screen.flip()
oldpad = pad
end
Добавлено спустя 23 минуты 3 секунды:Просмотр.
Сообщение отредактировано 29 июня 2011 14:19. Редактировалось 2 раз(а)