|
Orpheon
|
 |
« 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) 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 PyGG2Cool. Now STOP USING TABS DAMNIT. Set your editor to replace tabs with 4 spaces :/ Uhh...I did that. 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
|
 |
« 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
|
 |
« 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
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
|
 |
« 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
|
 |
« 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
|
 |
« 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
|
(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: 
|
|
|
|
Orpheon
|
 |
« 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
Posts: 92
LEET™
|
 |
« Reply #147 on: September 13, 2011, 11:01:23 pm » |
|
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
|
 |
« Reply #149 on: September 14, 2011, 04:13:23 am » |
|
"break" means "exit the while loop". Your code won't work like that. Try: 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.
|
|
|
|