Do you teach a baby to walk or just carry it around all day?
Work on the framework use, ditch your hardcoded crap.
Printable View
Are you an idiot? There isn't even 111 lines there, only 70.
Also, I agree with TP, this is a help thread, not a learn how to walk thread. Take a little pride in your work please, don't hard code everything, otherwise your programs will be a giant mess of crap that no one will want to look at and you will go down in history with the other thousands of PSP lua noobs.
legacy check your operators..... more specifically, greater-then-equal-to... (it isn't => if you're stumped)
I've been looking over Red Squirrels CTF unpacker src. Any way this could be done in lua ?? (attached src)
Any help I could get achieving this would be greatly appreciated.
Thanks
~shizzy
It can be done relatively easily.
This should get you started:
Code:function string.Mbyte(s)
local r = {}
for i=1, string.len(s) do
table.insert(r, string.byte(string.sub(s, i, i)))
end
return r
end
function string.NMbyte(s)
local b = string.Mbyte(s)
local r = ""
for i, n in ipairs(b) do
r = r .. tostring(n)
end
return tonumber(r)
end
function string.stripNull(string)
local r,n = string.gsub(string,"%z.*$","")
if n ~= 1 then
return r
else return "" end
end
function readBits(stringa, l)
stringa = string.reverse(stringa)
local value = 0
for i=1, l / 8 do
value = value + string.byte(string.sub(stringa,i,i)) * (256 ^ (i - 1))
end
return value
end
function CPTFHeader(file)
return {
sig = file:read(4),
version = string.NMbyte(file:read(4)), --?
name = string.stripNull(file:read(8)),
magic = file:read(4),
checksum = file:read(4), --?
headercount = readBits(file:read(4), 32),
size = readBits(file:read(4), 32)
}
end
function CTFPatchHeader(file)
return {
name = string.stripNull(file:read(64)),
start = readBits(file:read(4), 32),
size = readBits(file:read(4), 32)
}
end
Also, the basic structure of a CTF:
[PTF file with modified header] (CPTFHeader)
[Patch files]
[Patch file headers] (CTFPatchHeader)
Gah, "repetitively". Damn you FF spellcheck!
I can't for the life of me figure out how to make a texture on a 3d object semi transparent, can someone help me out?
i'm not vary familiar with lua's 3D functions, however understanding openGL, and the pspgu, i'd suggest looking in the documentation for lua(which ever one your using, but i suspect pge?), for method calls which contain the word blend
i decided to give u on my script. i tried everything to get it working.
really, i could have sworn pge was 3D capable, however your more of an expert on it than me
It was in the plans but got dropped for stability for an earlier release. IWN is adding it back in as we speak and has a beta with pretty good support of it and he's made a few demonstrations of its abilities.
well than in that case fchaos, your going to want to look up sceGuBlendFunc(from what TP just said it should be just GuBlendFunc in lua) in the sdk documentation, http://psp.jim.sh/pspsdk-doc/group__...d3bf7d032c62b6
that should help at least somewhat, since many of the blending functions available(not the operations) are similar to opengl's available blending functions, i suggest also looking up glBlendFunc to get a more better understanding of how the different blending functions work, anywho hope this helps=-)
Alright then, I'll look into that, thanks for the replies.
Okay, Lua semi-noob here, and I have a problem with a walking animation in my first game.
Anyways, I blitted my character to the screen in a standing position. Using AnimLib v4.5, when right is pressed my player will walk right and play the walking animation. Everything works as it should except the animation is played on top of the standing still sprite, and it looks like a jumbled up mess.
So, my question - How, using AnimLib v4.5 (I think that's latest version, and are there easier ways to animate besides AnimLib?), do I have my sprite standing still, then when right is pressed the walking animation is played, then when right is released it goes back to standing still?
P.S. - Here's my code, and sorry if it's a mess...
Code:player1 = Image.load("player1.png")
player2 = Image.load("player2.png")
player3 = Image.load("player3.png")
player4 = Image.load("player4.png")
player5 = Image.load("player5.png")
player6 = Image.load("player6.png")
background = Image.load("paper1.png")
speed = "2"
Player = {pic = player1, width = 32, hieght = 48, x = 0, y = 211}
dofile("animLib.lua")
player = ANIM.new("player", "png", 6)
while true do
pad = Controls.read()
screen:clear()
screen:blit(0, 0, background, false)
screen:blit(Player.x, Player.y, Player.pic, true)
if pad:right() then
player:blit(Player.x, Player.y, 50)
Player.x = Player.x + speed
end
if pad:cross() then
speed = "4"
else
speed = "2"
end
screen:flip()
screen:waitVblankStart()
oldpad = pad
end
An easier way (but certainly not the best way) to animate would be to :
Thats off the top of my head I haven't done any debugging but it should work.Code:function animate(x,y,startx,starty,height,width,image)
framecount = framecount + 1
animtempo = 0
if framecount == 6 then
framecount = 0
animtempo = animtempo + 1
if animtempo == 1 then
screen:blit(x,y,image,startx,starty,height,width)
else
screen:blit(x,y,image,animtempo *width,starty,height,width)
end
end
end
PS: Use your whole spritesheet for this not the pieces of it
But that doesn't use input, he wants to actually be able to control his character.
What you posted was just for displaying an animation.
just make 4 functions similar to bnc9's example, called animateRight animateLeft animateUp and animateDown. Then just do:
if pad:right() then
animateRight()
end
if pad:left() then
animateLeft()
end
if pad:up() then
animateUp()
end
if pad:down() then
animateDown()
end
you would also have to move the character's x and y, accordingly, but I suspect that he knows how to do that already.
lol, I know that there is a better way to do it, but I was keeping it simple. Thank you for telling him a better way though.
Thanks guys, I'll go try those examples out!
I'm not sure I understand, but I'll try it and get back to ya! Thanks again.
While I'm here, I have a question on a different game, my first game, I'm making, so i'll go ahead and ask it :Jump:
I've been making my first game for a couple of days now, and it's almost done.
In the game, you control a space ship - [X] makes the ship go up, [<] makes the ship go left, and [>] makes the ship go right. I've implemented some physics, so when you are not accelerating up, you will begin to fall, and if you are moving up and then let go of up then you will slow down, then begin to fall. The object of the game is to avoid asteroids as they fly across the screen.
Anyways, I need to know how I could do collision detection on the asteroids, which are not perfectly round as they contain craters and things like that, and my ship. I'm new to collision, but I do not think the basic collision tutorial (one on EvilMana) will work. So what could I use to achieve my goal? I haven't found hardly any collision tutorials...
Also, is it possible to do collision detection on spinning asteroids?
Thanks
And here's a screenshot to help understand how the game plays...
(Never Mind, I have to have 10 posts :))
@PSProgrammer: As TurtlesPwn said one function for all animations is better the example I posted allows you make animations for all directions instead of 4 hardcoded functions.
@cjmabry25: uhh this might help but it'll be a little difficult to implement in your game: http://www.forums.evilmana.com/index.php?topic=1412.15
check tacticalpenguins code and his explanation at the bottom.
It involves collision with lines rather than boxes.
You'll need to know a little bit about vectors to understand this.
Is there any way to encrypt or decrypt lua files?
Yes there is.
How?
If you use it you fail.
XtreamLua Compiler
No, it's called luac, xtreamlua's compiler is an idiotic frontend that just made it easy for the mass noobs to use. And it is not encryption or decryption, it is simply compiling. However, unless you have extremely good reason and understand how and why compiling your script would be needed, you shouldn't compile it, and I seriously doubt you have such understanding.
How can I switch between different main loops??? Like say I want to run gameA and I am currently playing gameB. How would I switch between the two. I have a variable called "layer" and its value tells my program which to do.
IGNORE THIS POST!!!!! I fixed my problem.
You should never have more than one main loop ...
How do I put .mp3 music in a lua script?
You could open the lua script in notepad and drag and drop your mp3 on top of it.
What what i mean is how do i loop it so when i go to the certain script on my psp the music plays.
What would be the best type of collision for a fighting game?
i'd suggest a box collision first, than do a pixel collision if the box collision passes
Ok ill try it
You shouldn't need anything more accurate than box collision for a fighting game.