Page 1 of 2

C.O.C.K. ATTACK

Posted: Fri Feb 27, 2009 6:15 pm
by philnelson
I've been working a project in TIGsource.com's newest competition, the Cockpit Compo. I'm currently looking for a collaborator to help with the code (esp. GUI elements), and since it's written in Love2d, I thought I'd post here to see if anyone was interested. You can see the status of the project and any mockups here: http://forums.tigsource.com/index.php?topic=4919.0

The (not great) code is available here: http://github.com/philnelson/cock-attack/tree/master

Re: C.O.C.K. ATTACK

Posted: Fri Feb 27, 2009 6:23 pm
by bartbes
Just finished reading the other thread. GREAT!!!
Too bad I'm not going to help...

I did read you got LUBE working? Another reason why I should love your game.
Ah.... *just enough reason left to push the submit button*

Re: C.O.C.K. ATTACK

Posted: Fri Feb 27, 2009 6:46 pm
by philnelson
Yes! LUBE is working, in fact. Right now it can just send strings back and forth (we implemented a super crude version of IRC basically). I may release that part of the code as a simple demo for LUBE. Once I can figure out a good way to create simple UI buttons and so forth, anyway.

Re: C.O.C.K. ATTACK

Posted: Fri Feb 27, 2009 6:50 pm
by bartbes
I already implemented IRC once on a hacked-up version of LUBE (it didn't support tcp back then).. well I'll wait and see what becomes of this wonderful mix of acronyms.

Re: C.O.C.K. ATTACK

Posted: Sun Mar 01, 2009 8:07 pm
by philnelson
Having a lot of trouble right now deciding on how to create "buttons" and so forth in the UI. I'm interested in how other people accomplish this.

The way I'm doing it is like this, in pseudocode:

Code: Select all

on mouse click
    if the click happened in between these X and Y coordinates
        do this stuff
    end
end
but I'm kind of stumbling w/r/t how to implement this in Love2d with the buttons corresponding to multiple, totally different, screens.

Re: C.O.C.K. ATTACK

Posted: Sun Mar 01, 2009 9:22 pm
by qubodup
philnelson wrote:but I'm kind of stumbling w/r/t how to implement this in Love2d with the buttons corresponding to multiple, totally different, screens.
My naive answer is: Create an "active" status for each button.

Another tipp: use the physics part of love to use clipping to know if the mouse is over a button at time of press.

Re: C.O.C.K. ATTACK

Posted: Sun Mar 01, 2009 11:07 pm
by osuf oboys
philnelson wrote:Having a lot of trouble right now deciding on how to create "buttons" and so forth in the UI. I'm interested in how other people accomplish this.

The way I'm doing it is like this, in pseudocode:

Code: Select all

on mouse click
    if the click happened in between these X and Y coordinates
        do this stuff
    end
end
but I'm kind of stumbling w/r/t how to implement this in Love2d with the buttons corresponding to multiple, totally different, screens.
I would suggest making the buttons object-oriented by keeping track of where they are, how they are drawn, and when they do when clicked. To assist you with this, you could use one of the existing GUI libraries. I would furthermore make each "screen" object-oriented, defining what UI components there are and how the screen is updated and drawn.

Re: C.O.C.K. ATTACK

Posted: Mon Mar 02, 2009 6:46 pm
by philnelson
What's the deal with Lua and referring to table data in mathematical comparisons? I'm trying to do this

Code: Select all

head_data = {tohit=6}

Code: Select all

tohit_roll = math.random(1,20)
if head_data.tohit <= tohit_roll then
    do stuff
end
but I get an error that says I'm trying to compare a number to nil. I can display head_data.tohit. It is most definitely NOT nil.

Re: C.O.C.K. ATTACK

Posted: Mon Mar 02, 2009 7:10 pm
by bartbes
Try asserting it all, it might be that the random function somehow fails, give-me-all-errors-you-can-generate code:

Code: Select all

head_data = {tohit=6}
assert(head_data, "head_data == nil")
assert(head_data.tohit, "head_data.tohit == nil")
tohit_roll = assert(math.random(1,20), "math.random(1,20) == nil")
if assert(head_data.tohit, "for loop can't read head_data.tohit") <= assert(tohit_roll, "for loop can't read tohit_roll") then
    do stuff
end
This should tell you what the problem is and where it's located.

Re: C.O.C.K. ATTACK

Posted: Mon Mar 02, 2009 7:11 pm
by philnelson
Ah, I didn't even know about assert. Useful! Thanks.