now it only shoots once each time
thanks yaustar
Quick hack fix
Note that I changed the images because I dont have any of them. The code I added could use cleaning depending on your coding style. Your main problem is that are lots of variables that were out of scope of the areas that needed them. Eg. Direction, currentBullet, oldpad.
---------player loading--------
player1 = Image.load("player.png")
player2 = Image.load("player.png")
player3 = Image.load("player.png")
player4 = Image.load("player.png")
morphball = Image.load("player.png")
-------backgound and other loading---
background = Image.load("player.png")
bullet = Image.load("bullet.png")
bullet1 = Image.load("bullet.png")
----player properties----
player = {}
player.img= player1
player.gravity = 190
player.y = 100
player.x = 200
player.jumpspeed = 10
player.jumpstate = "ground"
--Create Array for Bullets
BulletInfo = {}
for a = 1,5 do
BulletInfo[a] = { pic = bullet , firing = false, direction = "right", x = player.x + 32,
y = player.y + 16 }
end
currentBullet = 1
function bulletSetup(direction)
--Increase the current bullet by one, or reset it to 1
if currentBullet < 5 then
currentBullet = currentBullet + 1
else
currentBullet = 1
end
if direction == "left" then
BulletInfo[currentBullet].x = player.x
BulletInfo[currentBullet].y = player.y + 16
end
if direction == "right" then
BulletInfo[currentBullet].x = player.x + 32
BulletInfo[currentBullet].y = player.y + 16
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 < 0 or BulletInfo[i].x > 480 or BulletInfo[i].y < 0 or BulletInfo[i].y > 272 then
BulletInfo[i].firing = false
end
end
end
playerdirection = "right"
function move()
rand=math.random(1,2)
if pad:left() and rand==1 then
player.x= player.x -4
player.img= player3
playerdirection = "left"
end
if pad:left() and rand==2 then
player.x= player.x -4
player.img= player4
playerdirection = "left"
end
if pad:right() and rand==1 then
player.x=player.x +4
player.img= player1
playerdirection = "right"
end
if pad:right() and rand==2 then
player.x= player.x +4
player.img= player2
playerdirection = "right"
end
end
pad = Controls.read()
oldpad = pad
while true do
oldpad = pad
pad = Controls.read()
screen:clear()
move()
screen:blit(0,0,background,false)
if pad:cross() and player.jumpstate == "ground" then player.jumpstate = "jumping"
end
if pad:circle() and oldpad:circle() ~= pad:circle() then
bulletSetup(playerdirection)
end
if pad:down() and player.jumpstate == "ground" then
player.img = morphball
end
if pad:right() and player.img == morphball then
player.x=player.x-4
end
if pad:left() and player.img == morphball then
player.x=player.x+4
end
if player.x >= 445 then
screen:clear()
dofile "credits.lua"
end
if player.jumpstate == "jumping" then
player.jumpspeed = player.jumpspeed - 0.5
player.gravity = player.gravity - player.jumpspeed
end
if player.gravity < 0 then
player.jumpstate = "falling"
end
if player.gravity < 190 and player.jumpstate == "falling" then
player.gravity = player.gravity + (player.jumpspeed + 3)
end
if player.gravity == 190 then
player.jumpspeed = 10
player.jumpstate = "ground"
end
if player.gravity > 190 then player.gravity = 230 end
player.y = player.gravity
screen:blit(player.x,player.y,player.img)
bulletFire()
screen.flip()
screen.waitVblankStart()
end
now it only shoots once each time
thanks yaustar
It shoots 5 for mine.
no i am sying it dosent shoot like one hundered each time u press circleOriginally Posted by yaustar
it shoots once for each time u press circle
So its a good thing right?
version 1.5 released
if i made missles would i need a whole new bullet system for the missles or can i use the same one and load it w/ a diffrent pic???
You can use the latter method:
"i use the same one and load it w/ a diffrent pic???"
You might want to have the bullets have a 'type' so that you can check if a bullet is a missile or a standard beam for damage calculation.
ok school is starting for me again
but i will still try to work on this game a hour and a half a day
and on weekends maybe even more
i have been very wrong about my realease dates so dont thak this as an positive one but 2.0 should be ready in 8/21/06
features will include
missles
morhball bomb's
morphball animation
healthbar
gameover screen
ability to go into 2 other rooms
just one thing m8, the animation of samus is not correct, her legs move to fast.
great mod
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks