Game making help.

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Lahst
Prole
Posts: 1
Joined: Thu Dec 09, 2010 9:30 pm

Game making help.

Post by Lahst »

http://www.youtube.com/watch?v=34JbhA154To ;; My general concept is based off of this.

My knowledge of LUA and programming in general is very minimal, but I do at least have a grasp of the very basics just by playing with LOVE.

So what I am asking is, does anyone have any basic coding tips that can help me get a game similar to this in concept?
Mainly I want:
-A character that moves and shoots. (Does not need any weight variables, flying around the screen is fine)
Shooting is the troublesome part.
-Enemies that can be destoryed.

Any tutorials designed for complete newbies would be awesome too. Every tutorial I have found seems to be really complex.

Would it be easier to do a side scrolling perspective rather than a Z variable for depth of space?

Hmm. I just feel so lost. >_>;
User avatar
Ryne
Party member
Posts: 444
Joined: Fri Jan 29, 2010 11:10 am

Re: Game making help.

Post by Ryne »

There arent really any "tips" that anyone can tell you, though if you know the language all of these things become very easy to do. Creating an player that flys around is very basic. I will give you the run down of how love works.

Basically there are 3 main callbacks of any game you create. These are love.load, love.update, and love.draw. Creating a player is easy. Here is the most basic form of a "player" you can create, as well as how to move him around.

Code: Select all


function love.load() -- this is where all of the loading takes place, like sounds, images, font's etc.

     player = {} -- here I created a table called player
     player.hp = 100 -- the player's HP
     player.x = 50 -- the players X variable
     player.y = 50 -- the players Y variable
     player.image = love.graphics.newImage("image.png") -- this is how you load an image

end

function love.update(dt)

 -- this is where all of your controls will go, which I won't show you becasue I'm not Zac, and I wan't you to learn.

end

function love.draw()

     love.graphics.draw(player.image, player.x, player.y) -- this draw's that image we loaded, and places it at player.x, and player.y

end
I typed all of this in the browser since I'm on a garbage PC at my brothers house and was too lazy to wait 10 minutes for notepad to open. So I apologize if sytax is a little off.

Your next step should be to figure out how to use "love.keyboard" (which you can check out in the wiki) to manipulate the "player.x" and "player.y" since the player image is being drawn at player.x, and player.y, manipulating them will move the image around the screen. Reefr to this tutorial for how to move things around http://love2d.org/wiki/Tutorial:Hamster_Ball
@rynesaur
User avatar
tentus
Inner party member
Posts: 1060
Joined: Sun Oct 31, 2010 7:56 pm
Location: Appalachia
Contact:

Re: Game making help.

Post by tentus »

One of the great things about Love is that you can peek at other people's code to see how they accomplished things, and often get permission from people to straight up emulate their code. For example, my game borrows enormous chunks from the Lovely Mario Bros game, with the blessing of Deecodeuh, the original author. In your case, you would probably want to ask Maurice if you can borrow some code from his Flying Game (http://love2d.org/forums/viewtopic.php?f=5&t=2128).
Kurosuke needs beta testers
User avatar
zac352
Party member
Posts: 496
Joined: Sat Aug 28, 2010 8:13 pm
Location: In your head.
Contact:

Re: Game making help.

Post by zac352 »

Here's a semi-useless tip: Lua is a programming language, LUA stands for "Learn Ur Acronyms".
It gnaws at some of us, (Including me,) so you probably shouldn't mess that up. :ultrahappy:

Now, as for a character that moves, shoots, and kills enemies, here's a super basic example: (Don't let it overwhelm you, I have a tendency to write tremendously oversized example scripts in the post editor ;) ) (You should probably paste it into gedit for the code highlighting, the comments are more obvious when blue.)

Code: Select all

player={ --store player data
    x=0,
    y=0
}
bullets={} --store all the bullets
enemies={} -- and enemies
function newbullet(x,y,vx,vy) --function to create new bullets
    local b={}
    b.x=x;
    b.y=y;
    b.vx=vx;
    b.vy=vy;
    table.insert(bullets,b)
    return b
end
function newenemie(x,y) --create enemies
    local e={}
    e.x=x;
    e.y=y;
    e.health=100;
    table.insert(enemies,e);
    return e
end
--Class stuff over, now for the actual example:
function love.load() --called when game loads
    for i=1,20 do
        newenemie(math.random(0,800),math.random(0,600)) --spawn them all over the map.
    end
end
function love.update(dt) --called every frame, usually 1/60th of a second
    for i,v in pairs(bullets) do --update the bullets and stuff
        v.x=v.x+v.vx*dt --update their position
        v.y=v.y+v.vy*dt
        local x,y=v.x,v.y
        for _,e in pairs(enemies) do --check to see if you murdered an enemy
            if x>e.x and y>e.y and x<e.x+16 and y<e.y+16 then --they're 16x16 as a default
                e.health=e.health-10 --take away 10 health
                table.remove(bullets,i) --delete the bullet
            end
        end
    end
    for i,v in pairs(enemies) do --update enemies
        if v.health<=0 then
            table.remove(enemies,i) --they died
        else --they're still alive, so they're going to crawl around randomly.
            local dir=math.random(0,math.pi*2) --random angle in radians
            e.x=e.x+math.sin(dir)*16*dt --16 pixels/sec
            e.y=e.y+math.cos(dir)*16*dt --This is just basic trig, don't worry about it if you don't get it.
        end
    end
end
function love.draw() --draws stuff, called every frame the same way update is
    love.graphics.setColor(0,0,0) --bullets are black
    for _,v in pairs(bullets) do
        love.graphics.point(v.x,v.y) --draw eet
    end
    love.graphics.setColor(0,0,255) --blue player!
    love.graphics.rectangle(player.x,player.y,16,16)
    love.graphics.setColor(0,255,0) --green enemies!
    for _,v in pairs(enemies) do
        love.graphics.rectangle(v.x,v.y,16,16)
    end
end
function love.keypressed(k) --called when you push a key on your keyboard
    if k=="left" or k=="a" then
        player.x=player.x-16 --yes, I know you have to hit the key repeatedly to move. This is only an example!
    elseif k=="right" or k=="d" then
        player.x=player.x+16 --goes the other direction
    elseif k=="up" or k=="w" then
        player.y=player.y-16 --The y value goes down from the top of the screen
    elseif k=="down" or k=="s" then
        player.y=player.y+16 --down
    end
    if k==" " or k=="return" then --may not be obvious, but that first one is a space.
        newBullet(player.x,player.y,10,math.random(-4,4)) --I know, he can only shoot right. This is an example script!
        --the random factor makes the bullets sort of spray.
        --Note: The collisions defined earlier suck, so these bullets have to go slow.
    end
end
Hello, I am not dead.
User avatar
Ryne
Party member
Posts: 444
Joined: Fri Jan 29, 2010 11:10 am

Re: Game making help.

Post by Ryne »

zac352 wrote:Here's a semi-useless tip: Lua is a programming language, LUA stands for "Learn Ur Acronyms".
It gnaws at some of us, (Including me,) so you probably shouldn't mess that up. :ultrahappy:

Now, as for a character that moves, shoots, and kills enemies, here's a super basic example: (Don't let it overwhelm you, I have a tendency to write tremendously oversized example scripts in the post editor ;) ) (You should probably paste it into gedit for the code highlighting, the comments are more obvious when blue.)

That's exactly why I said "-- this is where all of your controls will go, which I won't show you becasue I'm not Zac, and I wan't you to learn.", besides the fact that the code you provided may seem basic but in reality is advanced for someone with NO prior programming language, the code you provided deals with velocities and functions, as well as more math than is needed for him to learn. I haven't been programming long, but 2 months ago I would have found that overwhelming. Don't post entire games for people, it's better to just give them something basic to work with, then let them progress on their own. At least let him TRY before throwing more code at him.

Your assistance, I'm sure, is still appreciated, but it's just overboard.
@rynesaur
User avatar
zac352
Party member
Posts: 496
Joined: Sat Aug 28, 2010 8:13 pm
Location: In your head.
Contact:

Re: Game making help.

Post by zac352 »

Ryne wrote: Your assistance, I'm sure, is still appreciated, but it's just overboard.
I'm sorry, but when I was learning Lua I really had trouble finding out how everything went together, because the only resources I could ever find were really basic "print('Hello, world!')" scripts. :(
Hello, I am not dead.
User avatar
Ryne
Party member
Posts: 444
Joined: Fri Jan 29, 2010 11:10 am

Re: Game making help.

Post by Ryne »

zac352 wrote:
Ryne wrote: Your assistance, I'm sure, is still appreciated, but it's just overboard.
I'm sorry, but when I was learning Lua I really had trouble finding out how everything went together, because the only resources I could ever find were really basic "print('Hello, world!')" scripts. :(
What's going to happen now is the person asking for help is going to copy and paste your code, at most tweaking it slightly to get what he want's, because why would he try it himself if it's right in front of him. Obviously not everyone would, and I could be wrong about the OP, but more than not would just copy.

I think my post just before yours contained enough code, and a good amount of explanation to what he needed to do, then you came in and shit on my carefully worded, beginner friendly post, which would have lead to him actually learning something on his own, and this isn't the first time you've done it. I'm telling you all of this because I hope you will finally quit wondering why you have negative karma, since In know at least 3 of your -k are for this specific reason.

I know you think you're helping, but almost everytime you post that much code, it's RIGHT AFTER a post like mine, so we look at it like a slap in the face when we sit here and try to help the person without directly giving them the answer, then you jump in a toss an entire game up. Heres a script of what happens to every new programmer that comes to the forum:

Code: Select all

Newbie: Hey everyone, I wan't to make a platformer, can someone point me int he right direction
Zac: Sure, heres all of the code you will ever need EVER.

[INSERT GIANT FULLY PROGRAMMED GAME CODE HERE]
@rynesaur
User avatar
Mud
Citizen
Posts: 98
Joined: Fri Nov 05, 2010 4:54 am

Re: Game making help.

Post by Mud »

Ryne wrote:What's going to happen now is the person asking for help is going to copy and paste your code
And it won't work (because it was never tested) and he won't know why.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Game making help.

Post by Robin »

Ryne wrote:

Code: Select all

 -- this is where all of your controls will go, which I won't show you becasue I'm not Zac, and I wan't you to learn.
Excellent. :monocle:

I think we're done disciplining Zachary (I have no idea if that really is his name, but I'm using it anyway) for now.

@Lahst: if you're overwhelmed or if you miss information, don't hesitate to ask questions on this forum (or on #love if you use IRC). And if you don't understand zac, you can ignore him. If you feel he is actually helping you, great!

And above all, just try. Just doing things, even if they turn out to be dead wrong, will help you writing games. You may not "get" a lot of things at first, but that's how we all felt at some point, and it's going to get better.
Help us help you: attach a .love.
User avatar
zac352
Party member
Posts: 496
Joined: Sat Aug 28, 2010 8:13 pm
Location: In your head.
Contact:

Re: Game making help.

Post by zac352 »

You guys are taking what I did and turning it into a garbled mess. This is like showing someone how to use paypal, I show them all at once, and you show them how to sign up, and then you tell them how to enter their first name, then tell them to come back in 2 weeks and ask how to enter their last name. (That's probably a really bad analogy, but it still shows my point.)

If I take something, and see how I implement it in a real example, instead of a little function that I have no idea what it does, I learn better. You can't expect EVERYONE in the world to learn exactly like you, or otherwise we'd be nowhere. If one person didn't understand, it'd be a perfectly logical assumption that no one else in the world would be able to. Ryne tried to tell me that no one on this forum learns like that. I do. Do I not exist?
Hello, I am not dead.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 2 guests