Turrets -- v1.4 RELEASED [Both Directions!]
I decided to give it a try. So far, I can only place it. It's quite buggy. I added a few sounds. I just need to make it hurt Mario. Also see him like a bullet bill..
SNAPSHOTS
Turrets: Side by Side
Left: Editor
Right: In-game
Progress:
4/05/12
http://www.youtube.com/watch?v=FJG1dtnJ2qM
4/7/12
RELEASES:
v1.4
http://www.mediafire.com/?tjmkby9ghdd6335
NOTES:
Grabbing the turret isn't very effective. Do not attempt. Unless you want an error screen. I will fix this shortly.
For right now, it's only turrets facing the right. Enjoy you guys :D
Any bugs other than grabbing the turret are now fixed. You can't get harmed by the laser if you jump on it, but I will fix that tomorrow.
Thanks for being extremely patient!
Questions:
Do I have to place "Turret Laser"
No. I just put it there. Thought I should if it was needed in order to run the firing script.
SNAPSHOTS
Turrets: Side by Side
Left: Editor
Right: In-game
Progress:
4/05/12
http://www.youtube.com/watch?v=FJG1dtnJ2qM
4/7/12
RELEASES:
v1.4
http://www.mediafire.com/?tjmkby9ghdd6335
NOTES:
Grabbing the turret isn't very effective. Do not attempt. Unless you want an error screen. I will fix this shortly.
For right now, it's only turrets facing the right. Enjoy you guys :D
Any bugs other than grabbing the turret are now fixed. You can't get harmed by the laser if you jump on it, but I will fix that tomorrow.
Thanks for being extremely patient!
Questions:
Do I have to place "Turret Laser"
No. I just put it there. Thought I should if it was needed in order to run the firing script.
Last edited by Turtle95 on 11 Apr 2012, 05:11, edited 11 times in total.
You need a turret sprite? Because that one looks a bit out of place.
Nah. I think it's fine. It's not too bad.Pyr0saur wrote:You need a turret sprite? Because that one looks a bit out of place.
I'll find a way. Or--Let's have a turret design contest then? (hits desk) let's do this!fakeuser wrote:I suggest you make it's width one tile. This one is way too stable (it's COM lies in its bottom), how are you supposed to knock it down? In Portal they are made tall and narrow
Seriously, we shall have a turret design contest. Also if anyone would like to help, I am more than glad to allow extra help.
..You're kidding right? That's quite small.. and not detailed much.Pyr0saur wrote:
Here ya go.
I edited the original turret. Maybe now it looks better.
No shit. That's the point. It's supposed to look like it would fit in the game. Which one looks more like the goomba: Mine, or the one in the picture? As for the size, I don't know what you're talking about. 8-bit sprites are tiny. Here's a size comparison:Turtle95 wrote:..You're kidding right? That's quite small.. and not detailed much.Pyr0saur wrote:
Here ya go.
Yes, but in-game, the sprites are much bigger.Maurice wrote:Pyrosaur has the right idea.
I'll resize his turret. See where that goes.Maurice wrote:Compare to size of other portal props. The cube is 12x12 iirc.Turtle95 wrote:Yes, but in-game, the sprites are much bigger.Maurice wrote:Pyrosaur has the right idea.
EDIT:
Doesn't look too bad. It could use a bit more detail TBH. It fell through the floor.. wtf.
Saying the turret needs more detail is like saying the goomba needs more detail.
Alright, I suppose it is. It is indeed. I just wasn't sure at first. Anyway, I'm slightly resizing it in the code. Make it a bit menacing..Camewel wrote:Dude that goomba would have aged.
Someone give it wrinkles.
Pyrosaur's turret is pretty much perfectly suited to Mari0's environment, it's the right size and simplistic in graphical style.
Last edited by Turtle95 on 06 Apr 2012, 02:50, edited 1 time in total.
Sorry for interrupting, but I decided to try making a turret myself:
It's 16x32, so it's the size of big Mario. Dunno what size you guys were going for, but meh, thought it was a good size myself. Anyway, there it is.
It's 16x32, so it's the size of big Mario. Dunno what size you guys were going for, but meh, thought it was a good size myself. Anyway, there it is.
Hm.. That's better really. I do like em both. But--this proves more situated because Mario will be "threatened" by its height. Plus a bit more detail. (Where the guns pull out is shown, nice work dude!) The one problem I am having regardless, is the damn thing goes under the floor if you drop it under the floor. If you're reading this Maurice, please help me fix this.idiot9.0 wrote:Sorry for interrupting, but I decided to try making a turret myself:
It's 16x32, so it's the size of big Mario. Dunno what size you guys were going for, but meh, thought it was a good size myself. Anyway, there it is.
Oh shit guys this image stretches out over a whole 32 pixels everyone just run.Turtle95 wrote:But--this proves more situated because Mario will be "threatened" by its height.
There's a function to do with cubes being dropped that you may want to steal (cubedropped(), if I'm not mistaken), it stops you dropping the cube inside anything solid.Turtle95 wrote:The one problem I am having regardless, is the damn thing goes under the floor if you drop it under the floor. If you're reading this Maurice, please help me fix this.
Hm.. *goes to look at code*Camewel wrote:Oh shit guys this image stretches out over a whole 32 pixels everyone just run.Turtle95 wrote:But--this proves more situated because Mario will be "threatened" by its height.
There's a function to do with cubes being dropped that you may want to steal (cubedropped(), if I'm not mistaken), it stops you dropping the cube inside anything solid.Turtle95 wrote:The one problem I am having regardless, is the damn thing goes under the floor if you drop it under the floor. If you're reading this Maurice, please help me fix this.
Ah in cubedropper.lua.
How do I freaking call that? o_0
It IS the box.lua. It's only temporary. Dunno why it's not being used properly.Camewel wrote:No, box.lua.
Called it in floorcollide()
Nothing.
This is all the code (so far)
Code: Select all
box = class:new()
function box:init(x, y)
--PHYSICS STUFF
self.cox = x
self.coy = y
self.x = x-12/16
self.y = y-14/16
self.speedy = 0
self.speedx = 0
self.width = 12/16
self.height = 14/16
self.static = false
self.active = true
self.category = 9
self.parent = nil
self.portaloverride = true
self.mask = { true,
false, false, false, false, false,
false, true, false, true, true,
false, false, true, false, false,
true, true, false, false, true,
false, true, true, false, false,
true, false, true, true, true}
self.emancipatecheck = true
self.userect = adduserect(self.x, self.y, 12/16, 14/16, self)
--IMAGE STUFF
self.drawable = true
self.graphic = Turret
self.quad = Turretquad
self.offsetX = 6
self.offsetY = 6
self.quadcenterX = 6
self.quadcenterY = 6
self.rotation = 0 --for portals
self.falling = false
self.destroying = false
self.outtable = {}
self.portaledframe = false
end
function box:update(dt)
local friction = boxfrictionair
if self.falling == false then
friction = boxfriction
end
if not self.pushed then
if self.speedx > 0 then
self.speedx = self.speedx - friction*dt
if self.speedx < 0 then
self.speedx = 0
end
else
self.speedx = self.speedx + friction*dt
if self.speedx > 0 then
self.speedx = 0
end
end
else
self.pushed = false
end
--rotate back to 0 (portals)
self.rotation = math.mod(self.rotation, math.pi*2)
if self.rotation > 0 then
self.rotation = self.rotation - portalrotationalignmentspeed*dt
if self.rotation < 0 then
self.rotation = 0
end
elseif self.rotation < 0 then
self.rotation = self.rotation + portalrotationalignmentspeed*dt
if self.rotation > 0 then
self.rotation = 0
end
end
if self.parent then
local oldx = self.x
local oldy = self.y
self.x = self.parent.x+math.sin(-self.parent.pointingangle)*0.3
self.y = self.parent.y-math.cos(-self.parent.pointingangle)*0.3
if self.portaledframe == false then
for h, u in pairs(emancipationgrills) do
if u.dir == "hor" then
if inrange(self.x+6/16, u.startx-1, u.endx, true) and inrange(u.y-14/16, oldy, self.y, true) then
self:emancipate(h)
end
else
if inrange(self.y+6/16, u.starty-1, u.endy, true) and inrange(u.x-14/16, oldx, self.x, true) then
self:emancipate(h)
end
end
end
end
end
self.userect.x = self.x
self.userect.y = self.y
--check if offscreen
if self.y > 17 then
self:destroy()
end
self.portaledframe = false
if self.destroying then
return true
else
return false
end
end
function box:leftcollide(a, b)
if a == "button" then
self.y = b.y - self.height
self.x = b.x + b.width - 0.01
if self.speedy > 0 then
self.speedy = 0
end
return false
elseif a == "player" then
self.pushed = true
return false
end
end
function box:rightcollide(a, b)
if a == "button" then
self.y = b.y - self.height
self.x = b.x - self.width+0.01
if self.speedy > 0 then
self.speedy = 0
end
return false
elseif a == "player" then
self.pushed = true
return false
end
end
function box:floorcollide(a, b)
if self.falling then
self.falling = false
end
if a == "goomba" or a == "bulletbill" then
b:stomp()
addpoints(200, self.x, self.y)
playsound(stompsound)
self.falling = true
return false
end
box:dropped()
end
function box:passivecollide(a, b)
if a == "player" then
if self.x+self.width > b.x+b.width then
self.x = b.x+b.width
else
self.x = b.x-self.width
end
end
end
function box:startfall()
self.falling = true
end
function box:emancipate()
if self.parent then
self.parent:cubeemancipate()
end
self:destroy()
playsound(emancipater)
playsound(emancipated)
end
function box:destroy()
self.userect.delete = true
self.destroying = true
for i = 1, #self.outtable do
if self.outtable[i].input then
self.outtable[i]:input("toggle")
end
end
end
function box:addoutput(a)
table.insert(self.outtable, a)
end
function box:used(id)
self.parent = objects["player"][id]
self.active = false
objects["player"][id]:pickupbox(self)
speech = math.random(0, 4)
if speech == 0 then
playsound(who)
end
if speech == 1 then
playsound(please)
end
end
function box:dropped()
self.parent = nil
self.active = true
end
function box:portaled()
self.portaledframe = true
end
I agree. I saw your post where you were acting like Maurice and in a nutshell, he said, "approved" lol. But anywho, yea. Wake up Maurice.Camewel wrote:Wait for Maurice to wake up, he knows this code better than anyone else.
Well aren't you special.Elbow wrote:I made a really good SMB styled turret a while back. I suggest you use it, because honestly, the ones posted here don't look SMB styled, and they were drawn bad.
You don't have to be a complete jerk. It's nice, but too big and NES-y. Not great to look at while playing Mari0 though..Pyr0saur wrote:Well aren't you special.Elbow wrote:I made a really good SMB styled turret a while back. I suggest you use it, because honestly, the ones posted here don't look SMB styled, and they were drawn bad.
I don't? I think I need to go rethink my entire life.Turtle95 wrote:You don't have to be a complete jerk. It's nice, but too big and NES-y. Not great to look at while playing Mari0 though..Pyr0saur wrote:Well aren't you special.Elbow wrote:I made a really good SMB styled turret a while back. I suggest you use it, because honestly, the ones posted here don't look SMB styled, and they were drawn bad.
Progress of the mod is in a video in the first post. Enjoy what I have so far.
I think that Pyr0saur has a perfect sprite. It looks looks better inside the rest of the world. Now compared to the other turrets, not so much, but that's obviously because they have more room for detail. But they look out of place inside an 8-bit game...mostly because they're NOT 8-bit.
But it's up to you since you're the one making the mod after all.
But it's up to you since you're the one making the mod after all.
Ok. So mario:dropbox should be called in which,, Time to play around with that. I just woke up lol.Maurice wrote:mario:dropbox()
I am going to guess you changed the turret's height, so you'll need to replace 12/16 with whatever you got, and differenciate between box and turret.
EDIT: Edited the height you grab the "box". Changed it to 14. Now it's fine :D
Now. Time to fire dem lazors (yes, mis-spelled on purpose. Know your memes.)
I like the sounds, especially the emancipating turret! However some suggestionsTurtle95 wrote:Progress of the mod is in a video in the first post. Enjoy what I have so far.
- You have copied some mario.lua code to make turret physics? I am asking because the turret landed on its feet (like mario). That's exactly what you don't want a turret to do, when you portal it somewhere
- "Shutting down" sound and system error. Meaning tilted turret shut be offline
- That laser should really kill the turret. One of the best things of portal was burning the one-eyed monsters
- Turrets laser sight would be a cool feature
P.s. turret dropper?! WTF man?!
Thanks. I plan to do all that. It's not Mario its the box entity. That's why it comes out the cube dispenser lol. The sight is just a matter to address once it can shoot Mario. So far it is not drawing the laser and the people over at the LOVE forums have not gotten back on that. :/ but I'll try to put those in when I can. I'm not exactly on my pc right now.fakeuser wrote:I like the sounds, especially the emancipating turret! However some suggestionsTurtle95 wrote:Progress of the mod is in a video in the first post. Enjoy what I have so far.Nice work, hope you finish this.
- You have copied some mario.lua code to make turret physics? I am asking because the turret landed on its feet (like mario). That's exactly what you don't want a turret to do, when you portal it somewhere
- "Shutting down" sound and system error. Meaning tilted turret shut be offline
- That laser should really kill the turret. One of the best things of portal was burning the one-eyed monsters
- Turrets laser sight would be a cool feature
P.s. turret dropper?! WTF man?!
Camewel wrote:Just delete lines 70-82 of box.lua and it will no longer right itself.
Sorry just got back on my laptop. And how would that help? I'm just trying to fire a lazor (yes, meme intended). Lemme check the LOVE forums while I wait for your reply.
EDIT:
THIS is the code so far.
Code: Select all
box = class:new()
function box:init(x, y)
--PHYSICS STUFF
self.cox = x
self.coy = y
self.x = x-12/16
self.y = y-14/16
self.speedy = 0
self.speedx = 0
self.width = 12/16
self.height = 14/16
self.static = false
self.active = true
self.category = 9
self.parent = nil
self.portaloverride = true
self.mask = { true,
false, false, false, false, false,
false, true, false, true, true,
false, false, true, false, false,
true, true, false, false, true,
false, true, true, false, false,
true, false, true, true, true}
self.emancipatecheck = true
self.userect = adduserect(self.x, self.y, 12/16, 12/16, self)
--IMAGE STUFF
self.drawable = true
self.graphic = Turret
self.quad = Turretquad
self.offsetX = 6
self.offsetY = 6
self.quadcenterX = 6
self.quadcenterY = 6
self.rotation = 0 --for portals
self.falling = false
self.destroying = false
self.outtable = {}
self.portaledframe = false
end
function box:draw()
love.graphics.draw(lazerimg, self.x, self.y)
end
function box:update(dt)
local friction = boxfrictionair
if self.falling == false then
friction = boxfriction
end
if not self.pushed then
if self.speedx > 0 then
self.speedx = self.speedx - friction*dt
if self.speedx < 0 then
self.speedx = 0
end
else
self.speedx = self.speedx + friction*dt
if self.speedx > 0 then
self.speedx = 0
end
end
else
self.pushed = false
end
--rotate back to 0 (portals)
self.rotation = math.mod(self.rotation, math.pi*2)
if self.rotation > 0 then
self.rotation = self.rotation - portalrotationalignmentspeed*dt
if self.rotation < 0 then
self.rotation = 0
end
elseif self.rotation < 0 then
self.rotation = self.rotation + portalrotationalignmentspeed*dt
if self.rotation > 0 then
self.rotation = 0
end
end
if self.parent then
local oldx = self.x
local oldy = self.y
self.x = self.parent.x+math.sin(-self.parent.pointingangle)*0.3
self.y = self.parent.y-math.cos(-self.parent.pointingangle)*0.3
if self.portaledframe == false then
for h, u in pairs(emancipationgrills) do
if u.dir == "hor" then
if inrange(self.x+6/16, u.startx-1, u.endx, true) and inrange(u.y-14/16, oldy, self.y, true) then
self:emancipate(h)
end
else
if inrange(self.y+6/16, u.starty-1, u.endy, true) and inrange(u.x-14/16, oldx, self.x, true) then
self:emancipate(h)
end
end
end
end
end
self.userect.x = self.x
self.userect.y = self.y
--check if offscreen
if self.y > 17 then
self:destroy()
end
self.portaledframe = false
if self.destroying then
return true
else
return false
end
end
function box:leftcollide(a, b)
if a == "button" then
self.y = b.y - self.height
self.x = b.x + b.width - 0.01
if self.speedy > 0 then
self.speedy = 0
end
return false
elseif a == "player" then
self.pushed = true
return false
end
end
function box:rightcollide(a, b)
if a == "button" then
self.y = b.y - self.height
self.x = b.x - self.width+0.01
if self.speedy > 0 then
self.speedy = 0
end
return false
elseif a == "player" then
self.pushed = true
return false
end
end
function box:floorcollide(a, b)
if self.falling then
self.falling = false
end
if a == "goomba" or a == "bulletbill" then
b:stomp()
addpoints(200, self.x, self.y)
playsound(stompsound)
self.falling = true
return false
end
end
function box:passivecollide(a, b)
if a == "player" then
if self.x+self.width > b.x+b.width then
self.x = b.x+b.width
else
self.x = b.x-self.width
end
end
end
function box:startfall()
self.falling = true
speech = math.random(0, 1)
if speech == 0 then
playsound(wee)
end
end
function box:emancipate()
if self.parent then
self.parent:cubeemancipate()
end
self:destroy()
playsound(emancipater)
playsound(emancipated)
end
function box:destroy()
self.userect.delete = true
self.destroying = true
for i = 1, #self.outtable do
if self.outtable[i].input then
self.outtable[i]:input("toggle")
end
end
end
function box:addoutput(a)
table.insert(self.outtable, a)
end
function box:used(id)
self.parent = objects["player"][id]
self.active = false
objects["player"][id]:pickupbox(self)
if self.falling == false then
speech = math.random(0, 4)
if speech == 0 then
playsound(who)
end
if speech == 1 then
playsound(please)
end
end
end
function box:dropped()
self.parent = nil
self.active = true
end
function box:portaled()
self.portaledframe = true
end
Camewel wrote:Take out the bit that says '--rotate back to 0 (portals)' or the turret will eternally right itself and be unkillable.
It crashes if i take that out. BTW that's a comment, it has no effect.
EDIT:
Nvm. Its fine. Gotta make the turret work like in Portal/2 now. Gravity leans it.. idk if you guys would care.
I hope you have figured out yourself he didn't mean the comment, but the code below itTurtle95 wrote:Camewel wrote:Take out the bit that says '--rotate back to 0 (portals)' or the turret will eternally right itself and be unkillable.
It crashes if i take that out. BTW that's a comment, it has no effect.
Code: Select all
--rotate back to 0 (portals)
self.rotation = math.mod(self.rotation, math.pi*2)
if self.rotation > 0 then
self.rotation = self.rotation - portalrotationalignmentspeed*dt
if self.rotation < 0 then
self.rotation = 0
end
elseif self.rotation < 0 then
self.rotation = self.rotation + portalrotationalignmentspeed*dt
if self.rotation > 0 then
self.rotation = 0
end
end
fakeuser wrote:I hope you have figured out yourself he didn't mean the comment, but the code below itTurtle95 wrote:Camewel wrote:Take out the bit that says '--rotate back to 0 (portals)' or the turret will eternally right itself and be unkillable.
It crashes if i take that out. BTW that's a comment, it has no effect.Code: Select all
--rotate back to 0 (portals) self.rotation = math.mod(self.rotation, math.pi*2) if self.rotation > 0 then self.rotation = self.rotation - portalrotationalignmentspeed*dt if self.rotation < 0 then self.rotation = 0 end elseif self.rotation < 0 then self.rotation = self.rotation + portalrotationalignmentspeed*dt if self.rotation > 0 then self.rotation = 0 end end
Yea I figured that out. They are killable but they constantly play the shut down. I'll fix that. I wonder if the people at LOVE forms have responded.
fakeuser wrote:I wonder what are you asking themTurtle95 wrote: I wonder if the people at LOVE forms have responded.
Why the laser expects userdata when I draw the laser.
EDIT: Lawnboy, I see what you said there. Would I do the floorcollide:draw inside the box or main?
Sorry for double post, but one thing guys. I'm going to update the video in a bit. Just lemme hold a small and fun contest. .
+
Not that exact pic. Just lemme see some epic drawings of the turret ON FIIIIIRREE!
+
Not that exact pic. Just lemme see some epic drawings of the turret ON FIIIIIRREE!
Have tested for some time and I bet lazerimg is nil. That's exactly how I managed to get the "expected userdata" error message. Before drawing the image add a
and if you get an error like "Trying to concatenate a nil value" then I'm right. You should initialize it in the very beginning of the script file
As for box:draw(). Have you read game.lua? Boxes are part of objects table and are drawn in game_draw() function (that's why drawable and quads are set). If you want to have box:draw() called, then you have to edit game.lua as well or use some injections. Lua is not the brightest language when interceptions are needed, but here's a simple solution (add to box.lua or whatever you renamed it to)
Then move your drawing logic into box:draw() function. It has no place in floorcollide(). And there is no such thing as floorcollide:draw
Code: Select all
print("lazerimg = " .. lazerimg)
As for box:draw(). Have you read game.lua? Boxes are part of objects table and are drawn in game_draw() function (that's why drawable and quads are set). If you want to have box:draw() called, then you have to edit game.lua as well or use some injections. Lua is not the brightest language when interceptions are needed, but here's a simple solution (add to box.lua or whatever you renamed it to)
Code: Select all
real_draw = game_draw
game_draw = function()
for split = 1, #splitscreen do
love.graphics.translate((split-1)*width*16*scale/#splitscreen, yoffset*scale)
for j, w in pairs(objects["box"]) do
w:draw()
end
end
real_draw()
end
EDIT:
Updated the videos. Still, no lasers. Will get onto that.
YES I did make GLaDOS talk. Made one giant .ogg of the three separate files, put it in sounds, made the sound in main.lua, then played it when you have boxes. . er.. turrets.
EDIT 2:
Good news: Got the lasers drawn.
Bad news: they are not aligned on the turret.
Updated the videos. Still, no lasers. Will get onto that.
YES I did make GLaDOS talk. Made one giant .ogg of the three separate files, put it in sounds, made the sound in main.lua, then played it when you have boxes. . er.. turrets.
EDIT 2:
Good news: Got the lasers drawn.
Bad news: they are not aligned on the turret.