The Gang Garrison 2 Forum
May 21, 2013, 06:55:16 am *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Chat with us on IRC: http://ganggarrison.com/irc.html
Server: irc.esper.net, Channel: #gg2
 
   Home   Help Search Login Register  
Pages: « 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 »
  Print  
Author Topic: Official PyGG2 Development thread  (Read 37237 times)
Orpheon
Moderator
*****
Online Online

Posts: 5824


Developer


« Reply #135 on: September 12, 2011, 07:02:13 am »

Anyone want to point me towards something they want done? I'm learning python, but I'm not far enough into the mindset to just start doing things.

Umm, well...

-You can improve anything you see in the code which is buggy (collision code for example)
-You could try making other classes and a class-select screen
-You could try making weapons (Scattergun+Shot object)
-You could try making menus, atm it jumps right into the game
-You could try to make a map background separate from the foreground, and maybe do the wallmask loading from a string like it's in gg2.
-You could try making health and HUDs
-You could try to make a game mode, probably ctf first.
-You could go learn how Twisted works for later, because we'll probably be using that for the networking.

Only suggestions though.
Logged

Your mind is software. Program it.
Your body is a shell. Change it.
Death is a disease. Cure it.
Extinction is approaching. Fight it.
notajf
Guest
« Reply #136 on: September 12, 2011, 10:19:34 am »

Against all odds, it works. We have a collision response code.
(even though it's a bit buggy at times)

Code:
def objectCheckCollision(character):

# Check if an object has hit the wallmask:

hasCollided = False

character.rect.centerx = character.x-character.xRectOffset
character.rect.centery = character.y-character.yRectOffset

clip = character.rect.clip(character.root.map.rect)

#find where clip's top-left point is in both rectangles
x1 = clip.left - character.root.map.rect.left
y1 = clip.top  - character.root.map.rect.top
 
#cycle through clip's area of the hitmasks
for x in range(clip.width):
for y in range(clip.height):
#returns True if neither pixel is blank
if character.root.map.mask.get_at((x1+x, y1+y)) == 1:
hasCollided = True

if hasCollided:
return True
else:
return False



def characterHitObstacle(character):


# THIS IS THE NEW VERSION; STILL WITH x/y


    newX = character.x
    newY = character.y

    hspeed = character.hspeed
    vspeed = character.vspeed

    length = lengthdir(hspeed, vspeed)

    if length == 0:# You haven't moved; if this happens something went wrong

        print "You haven't moved, yet managed to collide with something."
        return False


    # hs and vs is the normalized vector of hspeed and vspeed.
    hs = character.hspeed/length
    vs = character.vspeed/length

    while True:
        if not objectCheckCollision(character):
            break

        character.x -= hs
        character.y -= vs

# return True

    # This is the left-over velocity.
    hs = hspeed
    vs = vspeed

# The character got pushed out, but now we need to let him move in the directions he's allowed to move.


    character.x += sign(hs)

    if not objectCheckCollision(character) and abs(hs) > 0:

        # There's still room to move on the left/right

        i = 1
        while i <= abs(hs) and not objectCheckCollision(character):

            character.x += sign(hs)
            i += 1
    else:

        # Stop horizontal movement
        character.hspeed = 0
        character.hs = 0


    if objectCheckCollision(character):
        character.x -= sign(hs)

    character.y += sign(vs)

    if not objectCheckCollision(character) and abs(vs) > 0:

        # There's still room to move on the left/right


        i = 1
        while i <= abs(vs) and not objectCheckCollision(character):

            character.y += sign(vs)
            i += 1

    else:
        # Stop vertical movement
        character.vspeed = 0
        character.vs = 0

    if objectCheckCollision(character):
        character.y -= sign(vs)

    return True

PyGG2
Cool.

Now STOP USING TABS DAMNIT. Set your editor to replace tabs with 4 spaces :/
Uhh...I did that.

Code:
Tab Width: 4
Insert spaces instead of the tabs: On
No you didn't, the code you pasted there has tabs not spaces
Logged
Orpheon
Moderator
*****
Online Online

Posts: 5824


Developer


« Reply #137 on: September 12, 2011, 10:24:55 am »

No you didn't, the code you pasted there has tabs not spaces
I still changed the options.
Logged

Your mind is software. Program it.
Your body is a shell. Change it.
Death is a disease. Cure it.
Extinction is approaching. Fight it.
notajf
Guest
« Reply #138 on: September 12, 2011, 10:46:29 am »

No you didn't, the code you pasted there has tabs not spaces
I still changed the options.
well, fix your code. maybe you confused tab width and tabs to spaces
Logged
Orpheon
Moderator
*****
Online Online

Posts: 5824


Developer


« Reply #139 on: September 12, 2011, 10:55:04 am »

No you didn't, the code you pasted there has tabs not spaces
I still changed the options.
well, fix your code. maybe you confused tab width and tabs to spaces
Or maybe you just read portions of code that I wrote before. :/

Look at the collision response.
Logged

Your mind is software. Program it.
Your body is a shell. Change it.
Death is a disease. Cure it.
Extinction is approaching. Fight it.
notajf
Guest
« Reply #140 on: September 12, 2011, 12:34:51 pm »

No you didn't, the code you pasted there has tabs not spaces
I still changed the options.
well, fix your code. maybe you confused tab width and tabs to spaces
Or maybe you just read portions of code that I wrote before. :/

Look at the collision response.
well fix the old code, inconsistency is the issue here
Logged
HUNT3R
Jr. Member
**
Offline Offline

Posts: 92


LEET™


« Reply #141 on: September 12, 2011, 08:09:50 pm »

Hey today was my first day of Programming class and we're going to learn Python a lot throughout the year

We learned loops, strings, Boolean objects (mostly did Pythonkara), functions/def?

I have a question, how do you know how how much indenting to do? Thats the only hard part so far.

I hope in 5 months or so to know enough to help you guys out with this.
Logged

LEET™
Orpheon
Moderator
*****
Online Online

Posts: 5824


Developer


« Reply #142 on: September 13, 2011, 01:41:31 am »

Hey today was my first day of Programming class and we're going to learn Python a lot throughout the year

We learned loops, strings, Boolean objects (mostly did Pythonkara), functions/def?

I have a question, how do you know how how much indenting to do? Thats the only hard part so far.

I hope in 5 months or so to know enough to help you guys out with this.
How much indenting?

Official is half a tab, or 4(?) spaces.
Normally you can configure your IDE/Text editor to do it when you hit tab.


And for one lesson you already learned a lot. Keep going.
Logged

Your mind is software. Program it.
Your body is a shell. Change it.
Death is a disease. Cure it.
Extinction is approaching. Fight it.
notajf
Guest
« Reply #143 on: September 13, 2011, 01:42:54 am »

Identing is simple, you increase after a colon, and decrease at the end of the block.
Logged
Orpheon
Moderator
*****
Online Online

Posts: 5824


Developer


« Reply #144 on: September 13, 2011, 10:07:12 am »

PyGG2 v0.1.5;

-Fixed a few minor bugs of the collision code
-Added a weapon class, a scattergun class and a scattergun sprite
-Added a function "point_direction" (this took a while)
-Made a character turn to face the mouse
« Last Edit: September 13, 2011, 10:07:36 am by Orpheon » Logged

Your mind is software. Program it.
Your body is a shell. Change it.
Death is a disease. Cure it.
Extinction is approaching. Fight it.
Psychopath
Developer In Training
*****
Offline Offline

Posts: 6814

Stop telling me to do things


« Reply #145 on: September 13, 2011, 10:20:18 am »

-Made a character turn to face the mouse

Don't forget that certain animations will require exceptions to that such as the eating and stabbing animations (and taunt animations if you want to prevent people from spinning around while taunting).
Logged

Quote from: IRC
(8:01:46 PM) Psychopath: I'm just wondering what the next hot thing to fall on my lap will be
(8:01:57 PM) Lynn1: a girl maybe?
(8:02:01 PM) Psychopath: Shocked
Orpheon
Moderator
*****
Online Online

Posts: 5824


Developer


« Reply #146 on: September 13, 2011, 12:26:19 pm »

-Made a character turn to face the mouse

Don't forget that certain animations will require exceptions to that such as the eating and stabbing animations (and taunt animations if you want to prevent people from spinning around while taunting).
Exceptions can easily be added later. And yes, I want to be able to change direction while taunting.

Also, I'd be really happy if someone could make the gun point to the mouse.
I made the function point_direction, the problem is the rotating sprite of course grows, but this isn't compensated by the draw positions.

Could someone please do this?
Logged

Your mind is software. Program it.
Your body is a shell. Change it.
Death is a disease. Cure it.
Extinction is approaching. Fight it.
HUNT3R
Jr. Member
**
Offline Offline

Posts: 92


LEET™


« Reply #147 on: September 13, 2011, 11:01:23 pm »

Code:

while not kara.treeFront():
  kara.move()
  break
while kara.treeFront():
  kara.putLeaf() and kara.move()
       

That's my code. I'll define it later.

The problem is when I execute it, the "ladybug" moves 1 space and stops. I want it to move forward when tree not in front and put leaf if tree in front.

later I'm going to try to turn right if tree in front.

Do you see any problems with this code guys? :/ I had a few problems with the "break" so I just increased the indent until it didn't give me a syntax error.

What is a syntax error anyway?
Logged

LEET™
notajf
Guest
« Reply #148 on: September 14, 2011, 01:46:42 am »

A syntax error means bad syntax: like grammar or puncutation.
Logged
Orpheon
Moderator
*****
Online Online

Posts: 5824


Developer


« Reply #149 on: September 14, 2011, 04:13:23 am »

"break" means "exit the while loop". Your code won't work like that.

Try:

Code:
while True:
    while no kara.treeFront():
        kara.move()

    kara.turnRight()
Logged

Your mind is software. Program it.
Your body is a shell. Change it.
Death is a disease. Cure it.
Extinction is approaching. Fight it.
Pages: « 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 »
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.478 seconds with 19 queries.