Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-02-07 Thread Charles Christie

I thought of doing that but figured that it would clutter inboxes or make it
seem like I was trying to artificially garner attention. I'll make a new
thread.

On 2/6/07, Rikard Bosnjakovic <[EMAIL PROTECTED]> wrote:


On 2/6/07, Charles Christie <[EMAIL PROTECTED]> wrote:

> Anyway, Let's see. The tools I need:
[...]

May I suggest you start a new thread? This thread of 50+ posts has
evolved a bit, and for newcomers it would be easier to do a follow up
of the actual content if it's pinned down with a proper subject and
the like.

Just my two cents.


--
- Rikard.



Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-02-06 Thread Rikard Bosnjakovic

On 2/6/07, Charles Christie <[EMAIL PROTECTED]> wrote:


Anyway, Let's see. The tools I need:

[...]

May I suggest you start a new thread? This thread of 50+ posts has
evolved a bit, and for newcomers it would be easier to do a follow up
of the actual content if it's pinned down with a proper subject and
the like.

Just my two cents.


--
- Rikard.


Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-02-06 Thread Luke Paireepinart

Charles Christie wrote:

>Wii will rock you

I lol'd.

Anyway, Let's see. The tools I need:

a clock. I suppose pygame.time.set_timer(pygame.USEREVENT + 1, 1000) 
would be correct.


That would set a timer that, every 1000 miliseconds (that's one 
second, right?), would call pygame.USEREVENT + 1 which would decrease 
the number in a variable I call "timeleft."


So then I could make pygame.USEREVENT + 1 = timeleft - 1 or something 
like that? (I'm pretty sure the syntax for that is wrong)

I don't think you are understanding the events correctly.
setting a timer for USEREVENT+1 will just make that event's type one 
higher than USEREVENT, there's no kind of incrementing going on other 
than that once during the declaration.

In essence, than you'd want to do is something along these lines:
pygame.time.set_timer(pygame.USEREVENT, 1000)

while 1:#game loop
 for event in pygame.event.get():#as usual
   if event.type == pygame.USEREVENT:#you wouldn't need the pygame here 
if you did a 'from pygame.locals import *'

 #this only happens 1ce a second
 timeleft -= 1
 if timeleft == 0:
   print 'TIME OUT!"


Then, every 1000 miliseconds it would decrease timeleft by one, right?
In the above code it would. but make sure you notice that the event 
itself does absolutely nothing, just like a keydown event or whatever.
You have to define what behavior you want to occur in the same way you 
would with any other event.


Then I could have something that causes a "game over" event that would 
wipe everything off of the screen and print "game over" and print your 
scores, right? and I could even have a sort of "max combo" counter 
thing, because that wouldn't be too hard to program either.

Yep!

HTH,
-Luke


Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-02-06 Thread Charles Christie

Wii will rock you


I lol'd.

Anyway, Let's see. The tools I need:

a clock. I suppose pygame.time.set_timer(pygame.USEREVENT + 1, 1000) would
be correct.

That would set a timer that, every 1000 miliseconds (that's one second,
right?), would call pygame.USEREVENT + 1 which would decrease the number in
a variable I call "timeleft."

So then I could make pygame.USEREVENT + 1 = timeleft - 1 or something like
that? (I'm pretty sure the syntax for that is wrong)

Then, every 1000 miliseconds it would decrease timeleft by one, right?

Then I could have something that causes a "game over" event that would wipe
everything off of the screen and print "game over" and print your scores,
right? and I could even have a sort of "max combo" counter thing, because
that wouldn't be too hard to program either.

On 2/6/07, Luke Paireepinart <[EMAIL PROTECTED]> wrote:


Charles Christie wrote:
> hmm. So to make a timer, I'd make an event that would, every second,
> subtract one from a number that I could call "timer?" I never thought
> of it that way. Actually, that's given me a new idea that would
> greatly simplify making a scoring system and a different way to
> control difficulty as well...
>
> Instead of 3 timers, I'd only need one. It would start at a number
> that would vary between levels, and every second the timer's value is
> decreased by one. Typing a letter correctly would add to the timer,
> and that could also vary from level to level. Not only that, but it
> would save me the time of making 3 diffrent timers. Thanks for the hint!
>
Sure!
I'm a bit ashamed to admit it, but I made a parallax side-scrolling game
where the scrolling was all controlled by different events... even the
player!
Well, what can I say... It was a game-programming competiton (72hrGDC),
so I guess that means that anything 'working' is good.
And we got it done on time.  :)
Anyway... Glad I sparked some innovation in you.
Are you considering competing in Pyweek in April?  It might be a good
break!  If you consider a week of late nights and rapid hacky coding to
be relaxing :P
Nevertheless, lots of fun.  Would be cool to see you there.
Let me know if you have any trouble getting the events to add themselves
to the queue.
http://72hourgdc.com/board/downloads.php
Our entry is called Wii Will Rock You if you want to check it out.
The music is good, at least. :)
> On 2/5/07, *Luke Paireepinart* <[EMAIL PROTECTED]
> > wrote:
>
>
>
> On 2/5/07, *Charles Christie* < [EMAIL PROTECTED]
> > wrote:
>
> I would like to ask you guys another question. If you feel in
> the mood to help me out, feel free... but it turns out that I
> don't have as much time as I had hoped, because they (my
> teachers) want something I can demonstrate out by early May.
> >.< I need to get moving on this, and find some sprites if I
> can't contact my cousin any time soon...
>
> Is there any way to get pygame to get the right y coordinates
> of a rect? because I would like to have my text on the right
> side of the screen and if I knew how to get that, it would be
> a walk in the park. I know you can do it with some sort of
> freaky math but I'm trying to figure out how. I'm pretty sure
> if I googled it longer I could have figured it out but I have
> 1 minute before I have to get out of this classroom...
>
> A more difficult problem is the timers. I would like to have
> three of them, but I don't know how to use the
> pygame.time.Clock() other than setting a framerate. Does
> anybody have an example of how to use pygame.time.Clock () to
> keep track of how much time has elapsed since an event and
> only start after everything else has loaded? Because it would
> suck to have the clocks start while the program is still
> loading. That would ruin people's scores.
>
>
> It's actually really simple to create custom timed events.
> so after you load all your data, make the events.
> for example, if you wanted to subtract fuel from the player every
> second & set a max time limit at 150 seconds, add a custom event
> that will trigger every second.
> then in your event processing, if the event has occured, decrement
> fuel and increment timeLimit.  When this reaches 150, end the
> program or whatever.
> look at pygame Event docs.
>
>
>




Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-02-06 Thread Luke Paireepinart

Charles Christie wrote:
hmm. So to make a timer, I'd make an event that would, every second, 
subtract one from a number that I could call "timer?" I never thought 
of it that way. Actually, that's given me a new idea that would 
greatly simplify making a scoring system and a different way to 
control difficulty as well...


Instead of 3 timers, I'd only need one. It would start at a number 
that would vary between levels, and every second the timer's value is 
decreased by one. Typing a letter correctly would add to the timer, 
and that could also vary from level to level. Not only that, but it 
would save me the time of making 3 diffrent timers. Thanks for the hint!



Sure!
I'm a bit ashamed to admit it, but I made a parallax side-scrolling game 
where the scrolling was all controlled by different events... even the 
player!
Well, what can I say... It was a game-programming competiton (72hrGDC), 
so I guess that means that anything 'working' is good.

And we got it done on time.  :)
Anyway... Glad I sparked some innovation in you.
Are you considering competing in Pyweek in April?  It might be a good 
break!  If you consider a week of late nights and rapid hacky coding to 
be relaxing :P

Nevertheless, lots of fun.  Would be cool to see you there.
Let me know if you have any trouble getting the events to add themselves 
to the queue.

http://72hourgdc.com/board/downloads.php
Our entry is called Wii Will Rock You if you want to check it out.
The music is good, at least. :)
On 2/5/07, *Luke Paireepinart* <[EMAIL PROTECTED] 
> wrote:




On 2/5/07, *Charles Christie* < [EMAIL PROTECTED]
> wrote:

I would like to ask you guys another question. If you feel in
the mood to help me out, feel free... but it turns out that I
don't have as much time as I had hoped, because they (my
teachers) want something I can demonstrate out by early May.
>.< I need to get moving on this, and find some sprites if I
can't contact my cousin any time soon...

Is there any way to get pygame to get the right y coordinates
of a rect? because I would like to have my text on the right
side of the screen and if I knew how to get that, it would be
a walk in the park. I know you can do it with some sort of
freaky math but I'm trying to figure out how. I'm pretty sure
if I googled it longer I could have figured it out but I have
1 minute before I have to get out of this classroom...

A more difficult problem is the timers. I would like to have
three of them, but I don't know how to use the
pygame.time.Clock() other than setting a framerate. Does
anybody have an example of how to use pygame.time.Clock () to
keep track of how much time has elapsed since an event and
only start after everything else has loaded? Because it would
suck to have the clocks start while the program is still
loading. That would ruin people's scores. 



It's actually really simple to create custom timed events.
so after you load all your data, make the events.
for example, if you wanted to subtract fuel from the player every
second & set a max time limit at 150 seconds, add a custom event
that will trigger every second.
then in your event processing, if the event has occured, decrement
fuel and increment timeLimit.  When this reaches 150, end the
program or whatever.
look at pygame Event docs.







Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-02-05 Thread Charles Christie

hmm. So to make a timer, I'd make an event that would, every second,
subtract one from a number that I could call "timer?" I never thought of it
that way. Actually, that's given me a new idea that would greatly simplify
making a scoring system and a different way to control difficulty as well...

Instead of 3 timers, I'd only need one. It would start at a number that
would vary between levels, and every second the timer's value is decreased
by one. Typing a letter correctly would add to the timer, and that could
also vary from level to level. Not only that, but it would save me the time
of making 3 diffrent timers. Thanks for the hint!

On 2/5/07, Luke Paireepinart <[EMAIL PROTECTED]> wrote:




On 2/5/07, Charles Christie <[EMAIL PROTECTED]> wrote:
>
> I would like to ask you guys another question. If you feel in the mood
> to help me out, feel free... but it turns out that I don't have as much time
> as I had hoped, because they (my teachers) want something I can demonstrate
> out by early May. >.< I need to get moving on this, and find some sprites if
> I can't contact my cousin any time soon...
>
> Is there any way to get pygame to get the right y coordinates of a rect?
> because I would like to have my text on the right side of the screen and if
> I knew how to get that, it would be a walk in the park. I know you can do it
> with some sort of freaky math but I'm trying to figure out how. I'm pretty
> sure if I googled it longer I could have figured it out but I have 1 minute
> before I have to get out of this classroom...
>
> A more difficult problem is the timers. I would like to have three of
> them, but I don't know how to use the pygame.time.Clock() other than
> setting a framerate. Does anybody have an example of how to use
> pygame.time.Clock () to keep track of how much time has elapsed since an
> event and only start after everything else has loaded? Because it would suck
> to have the clocks start while the program is still loading. That would ruin
> people's scores.


It's actually really simple to create custom timed events.
so after you load all your data, make the events.
for example, if you wanted to subtract fuel from the player every second &
set a max time limit at 150 seconds, add a custom event that will trigger
every second.
then in your event processing, if the event has occured, decrement fuel
and increment timeLimit.  When this reaches 150, end the program or
whatever.
look at pygame Event docs.





Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-02-05 Thread Luke Paireepinart

On 2/5/07, Charles Christie <[EMAIL PROTECTED]> wrote:


I would like to ask you guys another question. If you feel in the mood to
help me out, feel free... but it turns out that I don't have as much time as
I had hoped, because they (my teachers) want something I can demonstrate out
by early May. >.< I need to get moving on this, and find some sprites if I
can't contact my cousin any time soon...

Is there any way to get pygame to get the right y coordinates of a rect?
because I would like to have my text on the right side of the screen and if
I knew how to get that, it would be a walk in the park. I know you can do it
with some sort of freaky math but I'm trying to figure out how. I'm pretty
sure if I googled it longer I could have figured it out but I have 1 minute
before I have to get out of this classroom...

A more difficult problem is the timers. I would like to have three of
them, but I don't know how to use the pygame.time.Clock() other than
setting a framerate. Does anybody have an example of how to use
pygame.time.Clock () to keep track of how much time has elapsed since an
event and only start after everything else has loaded? Because it would suck
to have the clocks start while the program is still loading. That would ruin
people's scores.



It's actually really simple to create custom timed events.
so after you load all your data, make the events.
for example, if you wanted to subtract fuel from the player every second &
set a max time limit at 150 seconds, add a custom event that will trigger
every second.
then in your event processing, if the event has occured, decrement fuel and
increment timeLimit.  When this reaches 150, end the program or whatever.
look at pygame Event docs.


Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-02-05 Thread Bob the Hamster
On Mon, Feb 05, 2007 at 05:26:46PM -0500, Charles Christie wrote:
> 
>Is there any way to get pygame to get the right y coordinates of a rect?
>because I would like to have my text on the right side of the screen and
>if I knew how to get that, it would be a walk in the park. I know you can
>do it with some sort of freaky math but I'm trying to figure out how. I'm
>pretty sure if I googled it longer I could have figured it out but I have
>1 minute before I have to get out of this classroom...

What you want to do can be done. Easily. 
http://www.pygame.org/docs/ref/rect.html is your friend.

---
Bob the Hamster


Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-02-05 Thread Charles Christie

I would like to ask you guys another question. If you feel in the mood to
help me out, feel free... but it turns out that I don't have as much time as
I had hoped, because they (my teachers) want something I can demonstrate out
by early May. >.< I need to get moving on this, and find some sprites if I
can't contact my cousin any time soon...

Is there any way to get pygame to get the right y coordinates of a rect?
because I would like to have my text on the right side of the screen and if
I knew how to get that, it would be a walk in the park. I know you can do it
with some sort of freaky math but I'm trying to figure out how. I'm pretty
sure if I googled it longer I could have figured it out but I have 1 minute
before I have to get out of this classroom...

A more difficult problem is the timers. I would like to have three of them,
but I don't know how to use the pygame.time.Clock() other than setting a
framerate. Does anybody have an example of how to use pygame.time.Clock() to
keep track of how much time has elapsed since an event and only start after
everything else has loaded? Because it would suck to have the clocks start
while the program is still loading. That would ruin people's scores.

On 2/4/07, Charles Christie <[EMAIL PROTECTED]> wrote:


Ha~! I got it working! I went over my code and compared it to a pygame
example, and noticed I didn't add my new classes to the "all.add(textsprite)"
at the bottom! Well, now it works, but it places the text in the wrong
place. I know how to fix that, though! I will have to change parts of the
code to be owned by the textsprite class so that the scoring class can
access it later, though. Things are definitely shaping up! If my commenting
on my progress is getting annoying or if I should only ask for help and not
send messages like this, then just say so. I'm still VERY new to this
mailing list thing and I'm really excited and loaded up with sugar right
now, so forgive my overenthusiasm.

I'm going to go and ask the guy that's helping me with sound how far he's
gotten later. If you see anything wrong with the code, or see any places I
can improve, can you just say something? I want to get as good at this as I
can and I'm willing to invest as much time as I need to in order to make
this something memorable and net me that A+ that I really want. ;)

On 2/2/07, Charles Christie <[EMAIL PROTECTED]> wrote:
>
> Crap. My hard drive died. Good thing I backed this thing up, huh? Well,
> now that I've recovered, I will post the code as an attatchment like I said
> I would. Here you go.
>
> On 1/31/07, Charles Joseph Christie II <[EMAIL PROTECTED]> wrote:
> >
> > I figured I was doing something wrong... I didn't know I could include
> > attachments. Sorry, this is really the first experience I've had with
> > a mailing list...
> >
> > A few e-mails up, I said I was trying to get the game to display the
> > letters and words you typed correctly in a row. Someone said to put
> > the
> > sprites in their own group, so I thought he meant class. So that's
> > what
> > I did. Yet, the text still doesn't show up on screen... What am I
> > doing
> > wrong?
> >
> > Yeah. So when I get back to my laptop I'll attach the code instead of
> > sending it in the body of my message next time. Sorry about that.
> >
> > On Tue, 30 Jan 2007 16:26:30 -0600
> > Luke Paireepinart < [EMAIL PROTECTED]> wrote:
> >
> > > Charles Christie wrote:
> > > > Aww it still doesn't work... am I doin' it right?
> > > What doesn't work?
> > > it's easier to give you help if you explain the problem you're
> > having
> > > and only include
> > > code snippets you think are relevant...
> > > I have zero desire to read through all your code and try to figure
> > > out what the problem is,
> > > especially since if you think there is a problem you probably know
> > > approximately where it is occurring...
> > > :)
> > > Also attachments are better than including the whole thing in your
> > > e-mail because then you can be
> > > sure that it isn't messing up your tabs, and you won't have problems
> > > with wrapping
> > > -Luke
> >
>
>
>




Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-02-04 Thread Charles Christie

Ha~! I got it working! I went over my code and compared it to a pygame
example, and noticed I didn't add my new classes to the "all.add(textsprite)"
at the bottom! Well, now it works, but it places the text in the wrong
place. I know how to fix that, though! I will have to change parts of the
code to be owned by the textsprite class so that the scoring class can
access it later, though. Things are definitely shaping up! If my commenting
on my progress is getting annoying or if I should only ask for help and not
send messages like this, then just say so. I'm still VERY new to this
mailing list thing and I'm really excited and loaded up with sugar right
now, so forgive my overenthusiasm.

I'm going to go and ask the guy that's helping me with sound how far he's
gotten later. If you see anything wrong with the code, or see any places I
can improve, can you just say something? I want to get as good at this as I
can and I'm willing to invest as much time as I need to in order to make
this something memorable and net me that A+ that I really want. ;)

On 2/2/07, Charles Christie <[EMAIL PROTECTED]> wrote:


Crap. My hard drive died. Good thing I backed this thing up, huh? Well,
now that I've recovered, I will post the code as an attatchment like I said
I would. Here you go.

On 1/31/07, Charles Joseph Christie II <[EMAIL PROTECTED]> wrote:
>
> I figured I was doing something wrong... I didn't know I could include
> attachments. Sorry, this is really the first experience I've had with
> a mailing list...
>
> A few e-mails up, I said I was trying to get the game to display the
> letters and words you typed correctly in a row. Someone said to put the
> sprites in their own group, so I thought he meant class. So that's what
> I did. Yet, the text still doesn't show up on screen... What am I doing
> wrong?
>
> Yeah. So when I get back to my laptop I'll attach the code instead of
> sending it in the body of my message next time. Sorry about that.
>
> On Tue, 30 Jan 2007 16:26:30 -0600
> Luke Paireepinart < [EMAIL PROTECTED]> wrote:
>
> > Charles Christie wrote:
> > > Aww it still doesn't work... am I doin' it right?
> > What doesn't work?
> > it's easier to give you help if you explain the problem you're having
> > and only include
> > code snippets you think are relevant...
> > I have zero desire to read through all your code and try to figure
> > out what the problem is,
> > especially since if you think there is a problem you probably know
> > approximately where it is occurring...
> > :)
> > Also attachments are better than including the whole thing in your
> > e-mail because then you can be
> > sure that it isn't messing up your tabs, and you won't have problems
> > with wrapping
> > -Luke
>





typinggame.py
Description: Binary data


helpers.py
Description: Binary data


Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-02-02 Thread Charles Christie

Crap. My hard drive died. Good thing I backed this thing up, huh? Well, now
that I've recovered, I will post the code as an attatchment like I said I
would. Here you go.

On 1/31/07, Charles Joseph Christie II <[EMAIL PROTECTED]> wrote:


I figured I was doing something wrong... I didn't know I could include
attachments. Sorry, this is really the first experience I've had with
a mailing list...

A few e-mails up, I said I was trying to get the game to display the
letters and words you typed correctly in a row. Someone said to put the
sprites in their own group, so I thought he meant class. So that's what
I did. Yet, the text still doesn't show up on screen... What am I doing
wrong?

Yeah. So when I get back to my laptop I'll attach the code instead of
sending it in the body of my message next time. Sorry about that.

On Tue, 30 Jan 2007 16:26:30 -0600
Luke Paireepinart <[EMAIL PROTECTED]> wrote:

> Charles Christie wrote:
> > Aww it still doesn't work... am I doin' it right?
> What doesn't work?
> it's easier to give you help if you explain the problem you're having
> and only include
> code snippets you think are relevant...
> I have zero desire to read through all your code and try to figure
> out what the problem is,
> especially since if you think there is a problem you probably know
> approximately where it is occurring...
> :)
> Also attachments are better than including the whole thing in your
> e-mail because then you can be
> sure that it isn't messing up your tabs, and you won't have problems
> with wrapping
> -Luke



helpers.py
Description: Binary data


typinggame.py
Description: Binary data


Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-01-30 Thread Charles Joseph Christie II
I figured I was doing something wrong... I didn't know I could include
attachments. Sorry, this is really the first experience I've had with
a mailing list...

A few e-mails up, I said I was trying to get the game to display the
letters and words you typed correctly in a row. Someone said to put the
sprites in their own group, so I thought he meant class. So that's what
I did. Yet, the text still doesn't show up on screen... What am I doing
wrong?

Yeah. So when I get back to my laptop I'll attach the code instead of
sending it in the body of my message next time. Sorry about that.

On Tue, 30 Jan 2007 16:26:30 -0600
Luke Paireepinart <[EMAIL PROTECTED]> wrote:

> Charles Christie wrote:
> > Aww it still doesn't work... am I doin' it right? 
> What doesn't work?
> it's easier to give you help if you explain the problem you're having 
> and only include
> code snippets you think are relevant...
> I have zero desire to read through all your code and try to figure
> out what the problem is,
> especially since if you think there is a problem you probably know 
> approximately where it is occurring...
> :)
> Also attachments are better than including the whole thing in your 
> e-mail because then you can be
> sure that it isn't messing up your tabs, and you won't have problems 
> with wrapping
> -Luke


Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-01-30 Thread Greg Ewing

Charles Christie wrote:


I have, however, thought of a way to do the basic idea of yours. The
hard part would be the bullet patterns.


Instead of bullets, maybe there could be obstacles to
manoeuvre around, wandering monsters to avoid, etc.
Sort of a "typing rogue"... hmmm... you could find
scrolls with incantations you have to type in order
to invoke the spell... the faster you type, the more
powerful the effect...

--
Greg


Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-01-30 Thread Luke Paireepinart

Charles Christie wrote:
Aww it still doesn't work... am I doin' it right? 

What doesn't work?
it's easier to give you help if you explain the problem you're having 
and only include

code snippets you think are relevant...
I have zero desire to read through all your code and try to figure out 
what the problem is,
especially since if you think there is a problem you probably know 
approximately where it is occurring...

:)
Also attachments are better than including the whole thing in your 
e-mail because then you can be
sure that it isn't messing up your tabs, and you won't have problems 
with wrapping

-Luke


Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-01-30 Thread Charles Christie

Aww it still doesn't work... am I doin' it right?


#Credit to scriptedfun (http://www.scriptedfun.com) for the help with
the typing portion
#Still a very VERY barebones typing script. Next I have to work on
#the basic shoot-em-up part and get the scoring in place

import pygame
from pygame.locals import *
import helpers

SCREENRECT = Rect(0, 0, 640, 480)


class Textsprite(pygame.sprite.Sprite):
   def __init__(self, text):
   pygame.sprite.Sprite.__init__(self)
   self.text = text
   self.pos = 0
   self.current_string = 0
   self.poscmb = 0
   self.stringcmb = 0
   self.update()
   def update(self):
   self.image = pygame.font.Font(None,
36).render(self.text[self.current_string], 1, (0, 0, 0))
   self.highlight = pygame.font.Font(None,
36).render(self.text[self.current_string][:self.pos], 1, (0, 0, 255))
   self.image.blit(self.highlight, (0, 0))
   self.rect = self.image.get_rect()
   self.rect.center = pygame.display.get_surface().get_rect().center
   def keyin(self, key):
   if key == self.text[self.current_string][self.pos]:
   self.pos = self.pos + 1
   self.poscmb = self.poscmb + 1
   else:
   self.poscmb = 0
   if len(self.text[self.current_string]) == self.pos:
   self.pos = 0
   if self.current_string +1 == len(self.text):
   self.current_string = 0
   else:
   self.current_string = self.current_string + 1
   self.stringcmb = self.stringcmb + 1

class Poscombosprite(pygame.sprite.Sprite):
   def __init__(self):
   pygame.sprite.Sprite.__init__(self)
   self.update()
   def update(self):
   self.poscombo = pygame.font.Font(None, 18).render('Letters
correctly typed in a row:' + str(Textsprite.poscmb), 1, (0, 255, 0))
   self.poscombo.blit(self.poscombo, (50, 150))
   self.poscmbrect = self.poscombo.get_rect()
   self.poscmbrect.center = pygame.display.get_surface().get_rect().center

class Stringcombosprite(pygame.sprite.Sprite):
   def __init__(self):
   pygame.sprite.Sprite.__init__(self)
   self.update()
   def update(self):
   self.stringcombo = pygame.font.Font(None, 18).render('Words
correctly typed in a row:' + str(Textsprite.stringcmb), 1, (255, 0,
0))
   self.stringcombo.blit(self.stringcombo, (50,50))
   self.stringcmbrect = self.stringcombo.get_rect()
   self.stringcmbrect.center =
pygame.display.get_surface().get_rect().center

def main():
   pygame.init()

   screen = pygame.display.set_mode(SCREENRECT.size)

   # make background
   background = pygame.Surface(SCREENRECT.size).convert()
   background.fill((255, 255, 255))
   screen.blit(background, (0, 0))
   pygame.display.update()

   # keep track of sprites
   all = pygame.sprite.RenderUpdates()

   # keep track of time
   clock = pygame.time.Clock()

   textsprite = Textsprite(["test string1", "another test!", "can you
type this?", "Hey Mr Ottman!", "It works!"])
   all.add(textsprite)

   #Set moving to false
   moving = 0

   # game loop
   while 1:

   # get input
   for event in pygame.event.get():
   if event.type == QUIT:
   return
   elif event.type == KEYUP:
   if event.key == K_TAB:
   moving = 0
   elif event.type == KEYDOWN:
   if event.key == K_ESCAPE:
   return
   elif event.key == K_TAB:
   moving = 1
   elif moving == 0:
   textsprite.keyin(event.unicode)

   # clear sprites
   all.clear(screen, background)

   # update sprites
   all.update()

   # redraw sprites
   dirty = all.draw(screen)
   pygame.display.update(dirty)

   # maintain frame rate
   clock.tick(30)

if __name__ == '__main__': main()


On 1/30/07, Charles Christie <[EMAIL PROTECTED]> wrote:

Yeah, that's a good idea, actually. But that would require a LOT more
strategy as to how to program the bullet patterns and gameplay itself.
I have, however, thought of a way to do the basic idea of yours. The
hard part would be the bullet patterns. They obviously wouldn't be
bullet hell, even on the hardest levels. I think my idea would be
easier to program but yours definitely, if I could think of a
practical idea for more of the game play, would be more... innovative.
Different. And different, as I always say, is good.

On 1/30/07, Luke Paireepinart <[EMAIL PROTECTED]> wrote:
> Charles Christie wrote:
> > Oh. :P
> >
> > Interesting idea, but I really have no clue on how to program
> > something like that...
> Another, probably more managable idea, is to lay words out on a +, so
> you type the up word to move up,
> the down word to move down, and some extra word if you want to shoot /
> bomb... etc.
> obviously when i say 'down word' i don't actually mean the word 'down.'
> >
> > On 1/30/07, Luke Paireepinart <[EMAIL PROTECTED]> wrote:
> 

Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-01-30 Thread Charles Christie

Yeah, that's a good idea, actually. But that would require a LOT more
strategy as to how to program the bullet patterns and gameplay itself.
I have, however, thought of a way to do the basic idea of yours. The
hard part would be the bullet patterns. They obviously wouldn't be
bullet hell, even on the hardest levels. I think my idea would be
easier to program but yours definitely, if I could think of a
practical idea for more of the game play, would be more... innovative.
Different. And different, as I always say, is good.

On 1/30/07, Luke Paireepinart <[EMAIL PROTECTED]> wrote:

Charles Christie wrote:
> Oh. :P
>
> Interesting idea, but I really have no clue on how to program
> something like that...
Another, probably more managable idea, is to lay words out on a +, so
you type the up word to move up,
the down word to move down, and some extra word if you want to shoot /
bomb... etc.
obviously when i say 'down word' i don't actually mean the word 'down.'
>
> On 1/30/07, Luke Paireepinart <[EMAIL PROTECTED]> wrote:
>> Charles Joseph Christie II wrote:
>> > Actually, you would only move if you held the "TAB" button, else you'd
>> > type.
>> >
>> He was suggesting an intriguing alternate control scheme,
>> not asking how your game worked :)
>> -Luke
>> >>> The thing is that moving would be mapped, on a qwerty keyboard:
>> >>> WASD, IKJL, and the up, 5, left and right buttons on a numpad.
>> >>>
>> >> There's an interesting idea in there somewhere. Suppose
>> >> movement was *only* done using alphabetic keys. Then the
>> >> words you typed would have the side effect of moving you
>> >> around in various ways. To allow you some freedom of
>> >> movement, you'd have a set of words to choose from at any
>> >> moment. The game would then be to choose which word to
>> >> type next to move you in the direction you want to go...
>> >>
>> >> --
>> >> Greg
>> >>
>> >
>> >
>>
>>
>




Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-01-30 Thread Luke Paireepinart

Charles Christie wrote:

Oh. :P

Interesting idea, but I really have no clue on how to program
something like that...
Another, probably more managable idea, is to lay words out on a +, so 
you type the up word to move up,
the down word to move down, and some extra word if you want to shoot / 
bomb... etc.

obviously when i say 'down word' i don't actually mean the word 'down.'


On 1/30/07, Luke Paireepinart <[EMAIL PROTECTED]> wrote:

Charles Joseph Christie II wrote:
> Actually, you would only move if you held the "TAB" button, else you'd
> type.
>
He was suggesting an intriguing alternate control scheme,
not asking how your game worked :)
-Luke
>>> The thing is that moving would be mapped, on a qwerty keyboard:
>>> WASD, IKJL, and the up, 5, left and right buttons on a numpad.
>>>
>> There's an interesting idea in there somewhere. Suppose
>> movement was *only* done using alphabetic keys. Then the
>> words you typed would have the side effect of moving you
>> around in various ways. To allow you some freedom of
>> movement, you'd have a set of words to choose from at any
>> moment. The game would then be to choose which word to
>> type next to move you in the direction you want to go...
>>
>> --
>> Greg
>>
>
>








Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-01-30 Thread Charles Christie

Oh. :P

Interesting idea, but I really have no clue on how to program
something like that...

On 1/30/07, Luke Paireepinart <[EMAIL PROTECTED]> wrote:

Charles Joseph Christie II wrote:
> Actually, you would only move if you held the "TAB" button, else you'd
> type.
>
He was suggesting an intriguing alternate control scheme,
not asking how your game worked :)
-Luke
>>> The thing is that moving would be mapped, on a qwerty keyboard:
>>> WASD, IKJL, and the up, 5, left and right buttons on a numpad.
>>>
>> There's an interesting idea in there somewhere. Suppose
>> movement was *only* done using alphabetic keys. Then the
>> words you typed would have the side effect of moving you
>> around in various ways. To allow you some freedom of
>> movement, you'd have a set of words to choose from at any
>> moment. The game would then be to choose which word to
>> type next to move you in the direction you want to go...
>>
>> --
>> Greg
>>
>
>




Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-01-30 Thread Luke Paireepinart

Charles Joseph Christie II wrote:

Actually, you would only move if you held the "TAB" button, else you'd
type.
  

He was suggesting an intriguing alternate control scheme,
not asking how your game worked :)
-Luke

The thing is that moving would be mapped, on a qwerty keyboard:
WASD, IKJL, and the up, 5, left and right buttons on a numpad.
  

There's an interesting idea in there somewhere. Suppose
movement was *only* done using alphabetic keys. Then the
words you typed would have the side effect of moving you
around in various ways. To allow you some freedom of
movement, you'd have a set of words to choose from at any
moment. The game would then be to choose which word to
type next to move you in the direction you want to go...

--
Greg



  




Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-01-29 Thread Charles Joseph Christie II
Actually, you would only move if you held the "TAB" button, else you'd
type.

On Tue, 30 Jan 2007 14:03:34 +1300
Greg Ewing <[EMAIL PROTECTED]> wrote:

> Charles Christie wrote:
> > The game would be about typing english words as fast as possible to
> > damage the boss, while moving around the bullet pattern it fires at
> > you.
> > 
> > The thing is that moving would be mapped, on a qwerty keyboard:
> > WASD, IKJL, and the up, 5, left and right buttons on a numpad.
> 
> There's an interesting idea in there somewhere. Suppose
> movement was *only* done using alphabetic keys. Then the
> words you typed would have the side effect of moving you
> around in various ways. To allow you some freedom of
> movement, you'd have a set of words to choose from at any
> moment. The game would then be to choose which word to
> type next to move you in the direction you want to go...
> 
> --
> Greg


Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-01-29 Thread Greg Ewing

Charles Christie wrote:

The game would be about typing english words as fast as possible to
damage the boss, while moving around the bullet pattern it fires at
you.

The thing is that moving would be mapped, on a qwerty keyboard:
WASD, IKJL, and the up, 5, left and right buttons on a numpad.


There's an interesting idea in there somewhere. Suppose
movement was *only* done using alphabetic keys. Then the
words you typed would have the side effect of moving you
around in various ways. To allow you some freedom of
movement, you'd have a set of words to choose from at any
moment. The game would then be to choose which word to
type next to move you in the direction you want to go...

--
Greg


Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-01-29 Thread Charles Christie

Ah, I get it. I remember there being a section in a pygame tutorial I
read having this in it, but if I put them in another sprite class, how
is it going to get the number of combos from the textsprite class to
blit on screen?

On 1/29/07, Patrick Mullen <[EMAIL PROTECTED]> wrote:

Ok, first I thought you weren't blitting the other text to the screen at
all, now I see that you are, but you are doing it inside another sprites
update() method.  The problem is that when you do

dirty = all.draw (screen)

It is only getting dirty rectangles for each sprite that is in all.  So it
is only updating the rectangle belonging to the textsprite.image.  The other
text displays should be individual sprites according to this architecture,
or you could have an overlay sprite that blits them to a larger .image.

Hope that helps you figure it out, although my description isn't so good.



Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-01-29 Thread Patrick Mullen

Ok, first I thought you weren't blitting the other text to the screen at
all, now I see that you are, but you are doing it inside another sprites
update() method.  The problem is that when you do

dirty = all.draw(screen)

It is only getting dirty rectangles for each sprite that is in all.  So it
is only updating the rectangle belonging to the textsprite.image.  The other
text displays should be individual sprites according to this architecture,
or you could have an overlay sprite that blits them to a larger .image.

Hope that helps you figure it out, although my description isn't so good.


Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-01-29 Thread Charles Christie

Alright my friends, I am in need of a little more help

I tried to have the game count combos but it's not displaying it on
screen. (After I get this working, I'll also try to get it to display
how many words you typed and how many words are left, and later
convert that into an HP bar, but that's thinking too far ahead)

*
#Credit to scriptedfun (http://www.scriptedfun.com) for the help with
the typing portion
#Still a very VERY barebones typing script. Next I have to work on
#the basic shoot-em-up part and get the scoring in place

import pygame
from pygame.locals import *
import helpers

SCREENRECT = Rect(0, 0, 640, 480)


class Textsprite(pygame.sprite.Sprite):
   def __init__(self, text):
   pygame.sprite.Sprite.__init__(self)
   self.text = text
   self.pos = 0
   self.current_string = 0
   self.poscmb = 0
   self.stringcmb = 0
   self.update()
   def update(self):
   self.image = pygame.font.Font(None,
36).render(self.text[self.current_string], 1, (0, 0, 0))
   self.highlight = pygame.font.Font(None,
36).render(self.text[self.current_string][:self.pos], 1, (0, 0, 255))
   self.stringcombo = pygame.font.Font(None, 18).render('Words
correctly typed in a row:' + str(self.stringcmb), 1, (255, 0, 0))
   self.poscombo = pygame.font.Font(None, 18).render('Letters
correctly typed in a row:' + str(self.poscmb), 1, (0, 255, 0))
   self.image.blit(self.highlight, (0, 0))
   self.stringcombo.blit(self.stringcombo, (50,50))
   self.poscombo.blit(self.poscombo, (50, 150))
   self.rect = self.image.get_rect()
   self.stringcmbrect = self.stringcombo.get_rect()
   self.poscmbrect = self.poscombo.get_rect()
   self.rect.center = pygame.display.get_surface().get_rect().center
   self.stringcmbrect.center =
pygame.display.get_surface().get_rect().center
   self.poscmbrect.center = pygame.display.get_surface().get_rect().center
   def keyin(self, key):
   if key == self.text[self.current_string][self.pos]:
   self.pos = self.pos + 1
   self.poscmb = self.poscmb + 1
   else:
   self.poscmb = 0
   if len(self.text[self.current_string]) == self.pos:
   self.pos = 0
   if self.current_string +1 == len(self.text):
   self.current_string = 0
   else:
   self.current_string = self.current_string + 1
   self.stringcmb = self.stringcmb + 1

def main():
   pygame.init()

   screen = pygame.display.set_mode(SCREENRECT.size)

   # make background
   background = pygame.Surface(SCREENRECT.size).convert()
   background.fill((255, 255, 255))
   screen.blit(background, (0, 0))
   pygame.display.update()

   # keep track of sprites
   all = pygame.sprite.RenderUpdates()

   # keep track of time
   clock = pygame.time.Clock()

   textsprite = Textsprite(["test string1", "another test!", "can you
type this?", "Hey Mr Ottman!", "It works!"])
   all.add(textsprite)

   #Set moving to false
   moving = 0

   # game loop
   while 1:

   # get input
   for event in pygame.event.get():
   if event.type == QUIT:
   return
   elif event.type == KEYUP:
   if event.key == K_TAB:
   moving = 0
   elif event.type == KEYDOWN:
   if event.key == K_ESCAPE:
   return
   elif event.key == K_TAB:
   moving = 1
   elif moving == 0:
   textsprite.keyin(event.unicode)

   # clear sprites
   all.clear(screen, background)

   # update sprites
   all.update()

   # redraw sprites
   dirty = all.draw(screen)
   pygame.display.update(dirty)

   # maintain frame rate
   clock.tick(30)

if __name__ == '__main__': main()
*

So, I can't figure out why the words aren't appearing on screen... I
looked through the pygame API documentation to make sure I was doing
it right, but it didn't help. Well, actually it kinda did (I had to
convert the  numbers to a string and it helped me there) but yeah, the
words don't actually show up. I wonder why?

On 1/29/07, Charles Christie <[EMAIL PROTECTED]> wrote:

The game would be about typing english words as fast as possible to
damage the boss, while moving around the bullet pattern it fires at
you.

The thing is that moving would be mapped, on a qwerty keyboard:
WASD, IKJL, and the up, 5, left and right buttons on a numpad.
I've never even seen a DVORAK keyboard so I would have no clue on how
to set it up for those.

I'm having a little more trouble but I'll ask about it later - I have
3D art class now, not senior project.

On 1/29/07, Luke Paireepinart <[EMAIL PROTECTED]> wrote:
> Charles Christie wrote:
> > Oh, and Luke, the game will be Open Source. So go ahead and modify it
> > for DVORAK or whatever. Do you really need to do that though? won't it
> > work fine with any kind of keyboard? Well, aside from the moving
> > par

Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-01-29 Thread Charles Christie

The game would be about typing english words as fast as possible to
damage the boss, while moving around the bullet pattern it fires at
you.

The thing is that moving would be mapped, on a qwerty keyboard:
WASD, IKJL, and the up, 5, left and right buttons on a numpad.
I've never even seen a DVORAK keyboard so I would have no clue on how
to set it up for those.

I'm having a little more trouble but I'll ask about it later - I have
3D art class now, not senior project.

On 1/29/07, Luke Paireepinart <[EMAIL PROTECTED]> wrote:

Charles Christie wrote:
> Oh, and Luke, the game will be Open Source. So go ahead and modify it
> for DVORAK or whatever. Do you really need to do that though? won't it
> work fine with any kind of keyboard? Well, aside from the moving
> parts. That would need modification for different keyboard types.
Yeah, it works fine for all kinds of keyboards.  but think about it:
stage 1 for qwerty:
    fjfjfjfj jfjfjfj etc.

stage 2:
df fd jk kj etc.

stage 1 on a dvorak:
uh huh uh huh etc.

stage 2 on a dvorak:
the hut het teh tut etc.

The layouts are different so the order in which you learn the keys is
different...
Unless your typing program is really just a speed test, then it doesn't
matter what layout it's for -
except that if you use english words us dvorak people will probably beat
you qwertyers ;)
I feel like that tale about the guy going up against the steam engine. :D

I hope this has enlightened you ;)
-Luke



Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-01-29 Thread Luke Paireepinart

Charles Christie wrote:

Oh, and Luke, the game will be Open Source. So go ahead and modify it
for DVORAK or whatever. Do you really need to do that though? won't it
work fine with any kind of keyboard? Well, aside from the moving
parts. That would need modification for different keyboard types. 

Yeah, it works fine for all kinds of keyboards.  but think about it:
stage 1 for qwerty:
    fjfjfjfj jfjfjfj etc.

stage 2:
df fd jk kj etc.

stage 1 on a dvorak:
uh huh uh huh etc.

stage 2 on a dvorak:
the hut het teh tut etc.

The layouts are different so the order in which you learn the keys is 
different...
Unless your typing program is really just a speed test, then it doesn't 
matter what layout it's for -
except that if you use english words us dvorak people will probably beat 
you qwertyers ;)

I feel like that tale about the guy going up against the steam engine. :D

I hope this has enlightened you ;)
-Luke


Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-01-29 Thread Charles Christie

Oh, and Luke, the game will be Open Source. So go ahead and modify it
for DVORAK or whatever. Do you really need to do that though? won't it
work fine with any kind of keyboard? Well, aside from the moving
parts. That would need modification for different keyboard types.

On 1/24/07, Charles Christie <[EMAIL PROTECTED]> wrote:

On 1/24/07, Luke Paireepinart <[EMAIL PROTECTED]> wrote:
> Sounds good.  What's this business about combos?
>
> Oh, and by the way, I'm in the process of writing a raycaster game engine.
> Thought that might interest you since you were thinking of making a
> first-person shooter typing game, right?
> I would be happy to help you modify it to suit your needs.
> I will probably GPL it, though, so I think that would mean you'd have to
> release your source or something.
> I dunno exactly what GPL does.  Anyway, I could give you a special
> license to use it probably, if GPL created issues for you.
> Let me know if you're interested.
> Oh, and is there any way you could add DVORAK support, or at least let
> me have the code and modify it myself?
> I'm trying to learn the DVORAK layout and most typing games I've found
> with support for that layout aren't very fun.
>
> -Luke


When I said "shoot-em-up" game I meant Touhou or R-type or something like
that, not a First Person Shooter, which is an entirely different concept.
And the combo thing is for scoring, but since the combo will only be
increased by how you type, it wouldn't make sense to have it be a global
variable.


Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-01-24 Thread Charles Christie

On 1/24/07, Luke Paireepinart <[EMAIL PROTECTED]> wrote:


Sounds good.  What's this business about combos?

Oh, and by the way, I'm in the process of writing a raycaster game engine.
Thought that might interest you since you were thinking of making a
first-person shooter typing game, right?
I would be happy to help you modify it to suit your needs.
I will probably GPL it, though, so I think that would mean you'd have to
release your source or something.
I dunno exactly what GPL does.  Anyway, I could give you a special
license to use it probably, if GPL created issues for you.
Let me know if you're interested.
Oh, and is there any way you could add DVORAK support, or at least let
me have the code and modify it myself?
I'm trying to learn the DVORAK layout and most typing games I've found
with support for that layout aren't very fun.

-Luke



When I said "shoot-em-up" game I meant Touhou or R-type or something like
that, not a First Person Shooter, which is an entirely different concept.
And the combo thing is for scoring, but since the combo will only be
increased by how you type, it wouldn't make sense to have it be a global
variable.


Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-01-24 Thread Luke Paireepinart

Charles Christie wrote:

Thanks luke, that did it!

My code now looks like this:
**
[snip]
   elif event.type == KEYDOWN:
   if event.key == K_ESCAPE:
   return
   elif event.key == K_TAB:
   moving = 1
   elif moving == 0:
   textsprite.keyin(event.unicode)

Hey, that's a good solution!
I didn't even think of trying to do it that way.


*

I made the game start recording how many keystrokes and words you get
right in a row. Next I just have to tell the game to render and blit
that value onto the screen (that goes in def update(self), am I
right?) and the combo system will be done.

Well, it depends how your code is logically separated.
Are combos an attribute of the textsprite class?
if that is the case, then update is probably a good place to put it.


Next I'd implement three timer systems, one for each combo counter and
one that dictates how long you have to complete the whole list of
words. If the timer runs out, the game prints "you loose" and starts
over.

Might want to have it say 'you lose' instead ;)


How does that sound?

Sounds good.  What's this business about combos?

Oh, and by the way, I'm in the process of writing a raycaster game engine.
Thought that might interest you since you were thinking of making a 
first-person shooter typing game, right?

I would be happy to help you modify it to suit your needs.
I will probably GPL it, though, so I think that would mean you'd have to 
release your source or something.
I dunno exactly what GPL does.  Anyway, I could give you a special 
license to use it probably, if GPL created issues for you.

Let me know if you're interested.
Oh, and is there any way you could add DVORAK support, or at least let 
me have the code and modify it myself?
I'm trying to learn the DVORAK layout and most typing games I've found 
with support for that layout aren't very fun.


-Luke


Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-01-23 Thread Charles Christie

Thanks luke, that did it!

My code now looks like this:
**
#Credit to scriptedfun (http://www.scriptedfun.com) for the help with
the typing portion
#Still a very VERY barebones typing script. Next I have to work on
#the basic shoot-em-up part and get the scoring in place

import pygame
from pygame.locals import *
import helpers

SCREENRECT = Rect(0, 0, 640, 480)


class Textsprite(pygame.sprite.Sprite):
   def __init__(self, text):
   pygame.sprite.Sprite.__init__(self)
   self.text = text
   self.pos = 0
   self.current_string = 0
   self.poscmb = 0
   self.stringcmb = 0
   self.update()
   def update(self):
   self.image = pygame.font.Font(None,
36).render(self.text[self.current_string], 1, (0, 0, 0))
   self.highlight = pygame.font.Font(None,
36).render(self.text[self.current_string][:self.pos], 1, (0, 0, 255))
   self.image.blit(self.highlight, (0, 0))
   self.rect = self.image.get_rect()
   self.rect.center = pygame.display.get_surface().get_rect().center
   def keyin(self, key):
   if key == self.text[self.current_string][self.pos]:
   self.pos = self.pos + 1
   self.poscmb = self.poscmb + 1
   else:
   self.poscmb = 0
   if len(self.text[self.current_string]) == self.pos:
   self.pos = 0
   if self.current_string +1 == len(self.text):
   self.current_string = 0
   else:
   self.current_string = self.current_string + 1
   self.stringcmb = self.stringcmb + 1

def main():
   pygame.init()

   screen = pygame.display.set_mode(SCREENRECT.size)

   # make background
   background = pygame.Surface(SCREENRECT.size).convert()
   background.fill((255, 255, 255))
   screen.blit(background, (0, 0))
   pygame.display.update()

   # keep track of sprites
   all = pygame.sprite.RenderUpdates()

   # keep track of time
   clock = pygame.time.Clock()

   textsprite = Textsprite(["test string1", "another test!", "can you
type this?", "Hey Mr Ottman!", "It works!"])
   all.add(textsprite)

   #Set moving to false
   moving = 0

   # game loop
   while 1:

   # get input
   for event in pygame.event.get():
   if event.type == QUIT:
   return
   elif event.type == KEYUP:
   if event.key == K_TAB:
   moving = 0
   elif event.type == KEYDOWN:
   if event.key == K_ESCAPE:
   return
   elif event.key == K_TAB:
   moving = 1
   elif moving == 0:
   textsprite.keyin(event.unicode)

   # clear sprites
   all.clear(screen, background)

   # update sprites
   all.update()

   # redraw sprites
   dirty = all.draw(screen)
   pygame.display.update(dirty)

   # maintain frame rate
   clock.tick(30)

if __name__ == '__main__': main()

*

I made the game start recording how many keystrokes and words you get
right in a row. Next I just have to tell the game to render and blit
that value onto the screen (that goes in def update(self), am I
right?) and the combo system will be done.

Next I'd implement three timer systems, one for each combo counter and
one that dictates how long you have to complete the whole list of
words. If the timer runs out, the game prints "you loose" and starts
over.

How does that sound?

On 1/23/07, Charles Christie <[EMAIL PROTECTED]> wrote:

> > It doesn't work... I can't quite figure it out. Am I missing a part?
> > It says my syntax is correct...
> syntax errors and logic errors are quite different beasts.
> just because your syntax is correct doesn't mean your program does what
> you want it to,
> just that it will do what you asked it to.
I know, I know, but what I meant to say is "I don't see the problem
and neither does the program".


> > At the very top of the file right after the import statements, I added
> > a line that reads:
> >
> > moving = 0
> >
> > After that, I changed this:
> >
> > def keyin(self, key):
> > if key == self.text[self.current_string][self.pos] and moving
> > == 0:
> Don't do this.  Have moving be local to the function with your main game
> loop,
> and pass it to keyin as an argument.  Global variables just confuse the
> issue.
> Functions should be self-contained.
>
Good idea! Thank you!
> HTH,
> -Luke
>



Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-01-23 Thread Charles Christie

> It doesn't work... I can't quite figure it out. Am I missing a part?
> It says my syntax is correct...
syntax errors and logic errors are quite different beasts.
just because your syntax is correct doesn't mean your program does what
you want it to,
just that it will do what you asked it to.

I know, I know, but what I meant to say is "I don't see the problem
and neither does the program".



> At the very top of the file right after the import statements, I added
> a line that reads:
>
> moving = 0
>
> After that, I changed this:
>
> def keyin(self, key):
> if key == self.text[self.current_string][self.pos] and moving
> == 0:
Don't do this.  Have moving be local to the function with your main game
loop,
and pass it to keyin as an argument.  Global variables just confuse the
issue.
Functions should be self-contained.


Good idea! Thank you!

HTH,
-Luke



Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-01-23 Thread Luke Paireepinart

Charles Christie wrote:
It doesn't work... I can't quite figure it out. Am I missing a part? 
It says my syntax is correct...

syntax errors and logic errors are quite different beasts.
just because your syntax is correct doesn't mean your program does what 
you want it to,

just that it will do what you asked it to.


At the very top of the file right after the import statements, I added 
a line that reads:


moving = 0

After that, I changed this:

def keyin(self, key):
if key == self.text[self.current_string][self.pos] and moving 
== 0:
Don't do this.  Have moving be local to the function with your main game 
loop,
and pass it to keyin as an argument.  Global variables just confuse the 
issue.

Functions should be self-contained.

HTH,
-Luke


Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-01-23 Thread Charles Christie

It doesn't work... I can't quite figure it out. Am I missing a part? It says
my syntax is correct...

At the very top of the file right after the import statements, I added a
line that reads:

moving = 0

After that, I changed this:

   def keyin(self, key):
   if key == self.text[self.current_string][self.pos] and moving == 0:

And I changed the bottom part to:

   for event in pygame.event.get():
   if event.type == QUIT:
   return
   elif event.type == KEYUP:
   if event.key == K_TAB:
   moving = 0
   elif event.type == KEYDOWN:
   if event.key == K_ESCAPE:
   return
   elif event.key == K_TAB:
   moving = 1
   else:
   textsprite.keyin(event.unicode)

It didn't work. I tried using the words "True" and "False" without the
quotes. It didn't work. I tried using moving is True instead of moving == 1
and it still didn't work.  I tried moving the statement moving = 0 into my
main(), and it didn't work. Argh. I think I'm missing something really
simple, but I can't place my finger on it...

On 1/22/07, Charles Christie <[EMAIL PROTECTED]> wrote:


Genius! Why didn't I think of that? I'll make a variable that will
react to the state of the TAB key called "moving". Pressing TAB makes
moving = 1 and releasing it changes it back to 0. Now, when moving =
1, keypresses won't register to the typing thinggy, and when moving =
0, the next part of the code I'm going to write (the basic shoot-em-up
part) the character doesn't move.

You guys are so helpful! Thanks!

On 1/22/07, Luke Paireepinart <[EMAIL PROTECTED]> wrote:
> Charles Christie wrote:
> > Sorry for spamming your email inboxes so much guys... I'm bad at this
> > whole email list thing... I'm better with forums, because I can edit
> > messages I post and stuff. Eh... Sorry.
> >
> > Anyway, now I want the Textsprite class to not accept input while the
> > K_TAB button is pressed.
> >
> > What would I have to code in this situation? I know that the program,
> > upon pressing TAB, should not negatively effect score (I've already
> > coded that part) but I don't know how to get it to actually stop
> > advancing the pointer as long as the TAB button is held down. I think
> > its because the advice I got was for an older version of pygame and
> > its not working.
> Not sure what you mean about the old version...
> I am using a dvorak keyboard, therefore my typing speed is quite
> hampered while my mind learns the new layout.
> So my reply will be short.  Didn't want you to think I was being
> disrespectful.
>
> Okay, basically the problem you have is that you want to do something
> when the tab key's state is raised, and something else when its state is
> depressed.
> This suggests an if/else structure, because the key can only be in two
> states: depressed or not.
>
> now how do we determine the state of the key? like this:
>
> tab_pressed = False#set this once, outside your game loop, not on each
> iteration
> for event in pygame.event.get():
>   if event.type == KEYDOWN:
> if event.key == K_TAB:
>   tab_pressed = True
> else:
>   #call your function here
>   elif event.type == K_UP:
> if event.key == K_TAB:
>   tab_pressed = False
>
> you'd probably want to add tab_pressed to your argument list for your
> keyin function.
> -Luke
>
>



Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-01-22 Thread Charles Christie

Genius! Why didn't I think of that? I'll make a variable that will
react to the state of the TAB key called "moving". Pressing TAB makes
moving = 1 and releasing it changes it back to 0. Now, when moving =
1, keypresses won't register to the typing thinggy, and when moving =
0, the next part of the code I'm going to write (the basic shoot-em-up
part) the character doesn't move.

You guys are so helpful! Thanks!

On 1/22/07, Luke Paireepinart <[EMAIL PROTECTED]> wrote:

Charles Christie wrote:
> Sorry for spamming your email inboxes so much guys... I'm bad at this
> whole email list thing... I'm better with forums, because I can edit
> messages I post and stuff. Eh... Sorry.
>
> Anyway, now I want the Textsprite class to not accept input while the
> K_TAB button is pressed.
>
> What would I have to code in this situation? I know that the program,
> upon pressing TAB, should not negatively effect score (I've already
> coded that part) but I don't know how to get it to actually stop
> advancing the pointer as long as the TAB button is held down. I think
> its because the advice I got was for an older version of pygame and
> its not working.
Not sure what you mean about the old version...
I am using a dvorak keyboard, therefore my typing speed is quite
hampered while my mind learns the new layout.
So my reply will be short.  Didn't want you to think I was being
disrespectful.

Okay, basically the problem you have is that you want to do something
when the tab key's state is raised, and something else when its state is
depressed.
This suggests an if/else structure, because the key can only be in two
states: depressed or not.

now how do we determine the state of the key? like this:

tab_pressed = False#set this once, outside your game loop, not on each
iteration
for event in pygame.event.get():
  if event.type == KEYDOWN:
if event.key == K_TAB:
  tab_pressed = True
else:
  #call your function here
  elif event.type == K_UP:
if event.key == K_TAB:
  tab_pressed = False

you'd probably want to add tab_pressed to your argument list for your
keyin function.
-Luke




Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-01-22 Thread Luke Paireepinart

Charles Christie wrote:

Sorry for spamming your email inboxes so much guys... I'm bad at this
whole email list thing... I'm better with forums, because I can edit
messages I post and stuff. Eh... Sorry.

Anyway, now I want the Textsprite class to not accept input while the
K_TAB button is pressed.

What would I have to code in this situation? I know that the program,
upon pressing TAB, should not negatively effect score (I've already
coded that part) but I don't know how to get it to actually stop
advancing the pointer as long as the TAB button is held down. I think
its because the advice I got was for an older version of pygame and
its not working.

Not sure what you mean about the old version...
I am using a dvorak keyboard, therefore my typing speed is quite 
hampered while my mind learns the new layout.
So my reply will be short.  Didn't want you to think I was being 
disrespectful.


Okay, basically the problem you have is that you want to do something 
when the tab key's state is raised, and something else when its state is 
depressed.
This suggests an if/else structure, because the key can only be in two 
states: depressed or not.


now how do we determine the state of the key? like this:

tab_pressed = False#set this once, outside your game loop, not on each 
iteration

for event in pygame.event.get():
 if event.type == KEYDOWN:
   if event.key == K_TAB:
 tab_pressed = True
   else:
 #call your function here
 elif event.type == K_UP:
   if event.key == K_TAB:
 tab_pressed = False

you'd probably want to add tab_pressed to your argument list for your 
keyin function.

-Luke



Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-01-22 Thread settrak
Hi,

don't worry for spamming, I guess that most of us are using filters to move 
pygame mails in a nice pygame folder :) therefore you do not 'pollute' our 
mails, you are just using the mailing list as it is intended to be used.

I looked at you program and I don't know why I liked it :P
What you are doing in your current code is reacting when the tab key is typed. 
But from what you are explaining that's not what you want to do. What you 
really want to do is react when all other keys are typed. And when one is 
pressed, you check the state of the tab key to verify if it is pressed or not.

Anyway, keep going, it's nice seeing a project advancing.

I'm not sure it's the cleanest way of doing it but here is the modification I 
made:

...
def keyin(self, key):
tab_is_pressed = pygame.key.get_pressed()[K_TAB]
if key == self.text[self.current_string][self.pos] and not 
tab_is_pressed:
self.pos = self.pos + 1
...


On Mon, 22 Jan 2007 13:49:54 -0500
"Charles Christie" <[EMAIL PROTECTED]> wrote:

> Sorry for spamming your email inboxes so much guys... I'm bad at this
> whole email list thing... I'm better with forums, because I can edit
> messages I post and stuff. Eh... Sorry.
> 
> Anyway, now I want the Textsprite class to not accept input while the
> K_TAB button is pressed.
> 
> What would I have to code in this situation? I know that the program,
> upon pressing TAB, should not negatively effect score (I've already
> coded that part) but I don't know how to get it to actually stop
> advancing the pointer as long as the TAB button is held down. I think
> its because the advice I got was for an older version of pygame and
> its not working.
> 


Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-01-22 Thread Charles Christie

Sorry for spamming your email inboxes so much guys... I'm bad at this
whole email list thing... I'm better with forums, because I can edit
messages I post and stuff. Eh... Sorry.

Anyway, now I want the Textsprite class to not accept input while the
K_TAB button is pressed.

What would I have to code in this situation? I know that the program,
upon pressing TAB, should not negatively effect score (I've already
coded that part) but I don't know how to get it to actually stop
advancing the pointer as long as the TAB button is held down. I think
its because the advice I got was for an older version of pygame and
its not working.


Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-01-22 Thread Charles Christie

At long last! I have it working perfectly!

*
#Credit to scriptedfun (http://www.scriptedfun.com) for the help with
the typing portion
#Stil a very VERY barebones typing script. Still got one last part of the main
#engine to go before getting to work on part two.

import pygame
from pygame.locals import *
import helpers

SCREENRECT = Rect(0, 0, 640, 480)

class Textsprite(pygame.sprite.Sprite):
   def __init__(self, text):
   pygame.sprite.Sprite.__init__(self)
   self.text = text
   self.pos = 0
   self.current_string = 0
   self.update()
   def update(self):
   self.image = pygame.font.Font(None,
36).render(self.text[self.current_string], 1, (0, 0, 0))
   self.highlight = pygame.font.Font(None,
36).render(self.text[self.current_string][:self.pos], 1, (0, 0, 255))
   self.image.blit(self.highlight, (0, 0))
   self.rect = self.image.get_rect()
   self.rect.center = pygame.display.get_surface().get_rect().center
   def keyin(self, key):
   if key == self.text[self.current_string][self.pos]:
   self.pos = self.pos + 1
   elif key == K_TAB:
   self.pos = self.pos
   else:
   self.combo = 0
   if len(self.text[self.current_string]) == self.pos:
   self.pos = 0
   if self.current_string +1 == len(self.text):
   self.current_string = 0
   else:
   self.current_string = self.current_string + 1

def main():
   pygame.init()

   screen = pygame.display.set_mode(SCREENRECT.size)

   # make background
   background = pygame.Surface(SCREENRECT.size).convert()
   background.fill((255, 255, 255))
   screen.blit(background, (0, 0))
   pygame.display.update()

   # keep track of sprites
   all = pygame.sprite.RenderUpdates()

   # keep track of time
   clock = pygame.time.Clock()

   textsprite = Textsprite(["test string1", "another test!", "can you
type this?", "Hey Mr Ottman!", "It works!"])
   all.add(textsprite)

   # game loop
   while 1:

   # get input
   for event in pygame.event.get():
   if event.type == QUIT:
   return
   elif event.type == KEYDOWN:
   if event.key == K_ESCAPE:
   return
   else:
   textsprite.keyin(event.unicode)

   # clear sprites
   all.clear(screen, background)

   # update sprites
   all.update()

   # redraw sprites
   dirty = all.draw(screen)
   pygame.display.update(dirty)

   # maintain frame rate
   clock.tick(30)

if __name__ == '__main__': main()
*

I'm so ecstatic! Weee! Thanks guys, you are a great help! Now,
what to work on next? I suppose the next part would be the basic
shoot-em-up part of the engine? (I'll put that in another python file
so I don't screw this one up) And then I'll do scoring. Well, at
least, that's a very basic and not-detailed roadmap for myself. I made
a much better one on my computer...

On 1/19/07, Charles Christie <[EMAIL PROTECTED]> wrote:

No. I guess I should, huh? Well, whatever. In any case, I've almost
got this thing working. But I forgot to add a line that resets the
program after the last word is typed... It gives some sort of "list
out of index" something or other error. I'm working on it... What I
need to do now is calculate the length of the list - I assume that it
is self.text as self.text[self.current_string] pulls a word out of the
list.
I tried this:

if len(self.text) == self.current_string:
self.current_string = 0
self.pos = 0
without success. Time to get to my next class, though, so I'll
troubleshoot this later...

On 1/17/07, Brandon N <[EMAIL PROTECTED]> wrote:
> Great progress!
>
> One question, are you backing up your code in between "breaking" it?
>
> On Jan 17, 2007, at 11:43 AM, Charles Christie wrote:
>
> > Good news everyone! I found out why I could never get anywhere:
> >
> > I was too afraid of breaking stuff so I didn't try to mess with
> > anything. However, if you don't break it, how can you fix it? So, I
> > looked over that pygame thing again and decided to just start doing
> > things that came to mind. It took me five minutes to get it working,
> > much faster than if I had begged someone to tell me how to do it.
> > Python really is a simple language after all, I think I really
> > understand this now! This is what my code looks like now:
> >
> > ***
> > #Credit to scriptedfun (http://www.scriptedfun.com) for the help with
> > the typing portion
> > #Stil a very VERY barebones typing script. Still got one last part
> > of the main
> > #engine to go before getting to work on part two.
> >
> > import pygame
> > from pygame.locals import *
> >
> > SCREENRECT = Rect(0, 0, 640, 480)
> >
> > class Textsprite(pygame.sprite.Sprite):
> >def __init__(self, text):
> >pygame.sprite.Sprite.__init__(self)
> >   

Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-01-19 Thread Charles Christie

No. I guess I should, huh? Well, whatever. In any case, I've almost
got this thing working. But I forgot to add a line that resets the
program after the last word is typed... It gives some sort of "list
out of index" something or other error. I'm working on it... What I
need to do now is calculate the length of the list - I assume that it
is self.text as self.text[self.current_string] pulls a word out of the
list.
I tried this:

   if len(self.text) == self.current_string:
   self.current_string = 0
   self.pos = 0
without success. Time to get to my next class, though, so I'll
troubleshoot this later...

On 1/17/07, Brandon N <[EMAIL PROTECTED]> wrote:

Great progress!

One question, are you backing up your code in between "breaking" it?

On Jan 17, 2007, at 11:43 AM, Charles Christie wrote:

> Good news everyone! I found out why I could never get anywhere:
>
> I was too afraid of breaking stuff so I didn't try to mess with
> anything. However, if you don't break it, how can you fix it? So, I
> looked over that pygame thing again and decided to just start doing
> things that came to mind. It took me five minutes to get it working,
> much faster than if I had begged someone to tell me how to do it.
> Python really is a simple language after all, I think I really
> understand this now! This is what my code looks like now:
>
> ***
> #Credit to scriptedfun (http://www.scriptedfun.com) for the help with
> the typing portion
> #Stil a very VERY barebones typing script. Still got one last part
> of the main
> #engine to go before getting to work on part two.
>
> import pygame
> from pygame.locals import *
>
> SCREENRECT = Rect(0, 0, 640, 480)
>
> class Textsprite(pygame.sprite.Sprite):
>def __init__(self, text):
>pygame.sprite.Sprite.__init__(self)
>self.text = text
>self.pos = 0
>self.current_string = 0
>self.update()
>def update(self):
>self.image = pygame.font.Font(None,
> 36).render(self.text[self.current_string], 1, (0, 0, 0))
>self.highlight = pygame.font.Font(None,
> 36).render(self.text[self.current_string][:self.pos], 1, (0, 0, 255))
>self.image.blit(self.highlight, (0, 0))
>self.rect = self.image.get_rect()
>self.rect.center = pygame.display.get_surface().get_rect
> ().center
>def keyin(self, key):
>if key == self.text[self.current_string][self.pos]:
>self.pos = self.pos + 1
>elif key == K_TAB:
>self.pos = self.pos
>else:
>self.combo = 0
>if len(self.text[self.current_string]) == self.pos:
>self.pos = 0
>self.current_string = self.current_string +1
>
> def main():
>pygame.init()
>
>screen = pygame.display.set_mode(SCREENRECT.size)
>
># make background
>background = pygame.Surface(SCREENRECT.size).convert()
>background.fill((255, 255, 255))
>screen.blit(background, (0, 0))
>pygame.display.update()
>
># keep track of sprites
>all = pygame.sprite.RenderUpdates()
>
># keep track of time
>clock = pygame.time.Clock()
>
>textsprite = Textsprite(["test string1", "another test!", "can you
> type this?"])
>all.add(textsprite)
>
># game loop
>while 1:
>
># get input
>for event in pygame.event.get():
>if event.type == QUIT:
>return
>elif event.type == KEYDOWN:
>if event.key == K_ESCAPE:
>return
>else:
>textsprite.keyin(event.unicode)
>
># clear sprites
>all.clear(screen, background)
>
># update sprites
>all.update()
>
># redraw sprites
>dirty = all.draw(screen)
>pygame.display.update(dirty)
>
># maintain frame rate
>clock.tick(30)
>
> if __name__ == '__main__': main()
> ***
>
> Now, there's just one problem, and I'm pretty sure you can see it:
> After the program goes through all the strings, it doesn't stop at the
> last one and tries to add one again. Which won't work, and the program
> will print an error about it going out of bounds. I'm working on that
> now, it should take no less than five or ten minutes to figure out.
> Thanks for all your help!




Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-01-17 Thread Brandon N

Great progress!

One question, are you backing up your code in between "breaking" it?

On Jan 17, 2007, at 11:43 AM, Charles Christie wrote:


Good news everyone! I found out why I could never get anywhere:

I was too afraid of breaking stuff so I didn't try to mess with
anything. However, if you don't break it, how can you fix it? So, I
looked over that pygame thing again and decided to just start doing
things that came to mind. It took me five minutes to get it working,
much faster than if I had begged someone to tell me how to do it.
Python really is a simple language after all, I think I really
understand this now! This is what my code looks like now:

***
#Credit to scriptedfun (http://www.scriptedfun.com) for the help with
the typing portion
#Stil a very VERY barebones typing script. Still got one last part  
of the main

#engine to go before getting to work on part two.

import pygame
from pygame.locals import *

SCREENRECT = Rect(0, 0, 640, 480)

class Textsprite(pygame.sprite.Sprite):
   def __init__(self, text):
   pygame.sprite.Sprite.__init__(self)
   self.text = text
   self.pos = 0
   self.current_string = 0
   self.update()
   def update(self):
   self.image = pygame.font.Font(None,
36).render(self.text[self.current_string], 1, (0, 0, 0))
   self.highlight = pygame.font.Font(None,
36).render(self.text[self.current_string][:self.pos], 1, (0, 0, 255))
   self.image.blit(self.highlight, (0, 0))
   self.rect = self.image.get_rect()
   self.rect.center = pygame.display.get_surface().get_rect 
().center

   def keyin(self, key):
   if key == self.text[self.current_string][self.pos]:
   self.pos = self.pos + 1
   elif key == K_TAB:
   self.pos = self.pos
   else:
   self.combo = 0
   if len(self.text[self.current_string]) == self.pos:
   self.pos = 0
   self.current_string = self.current_string +1

def main():
   pygame.init()

   screen = pygame.display.set_mode(SCREENRECT.size)

   # make background
   background = pygame.Surface(SCREENRECT.size).convert()
   background.fill((255, 255, 255))
   screen.blit(background, (0, 0))
   pygame.display.update()

   # keep track of sprites
   all = pygame.sprite.RenderUpdates()

   # keep track of time
   clock = pygame.time.Clock()

   textsprite = Textsprite(["test string1", "another test!", "can you
type this?"])
   all.add(textsprite)

   # game loop
   while 1:

   # get input
   for event in pygame.event.get():
   if event.type == QUIT:
   return
   elif event.type == KEYDOWN:
   if event.key == K_ESCAPE:
   return
   else:
   textsprite.keyin(event.unicode)

   # clear sprites
   all.clear(screen, background)

   # update sprites
   all.update()

   # redraw sprites
   dirty = all.draw(screen)
   pygame.display.update(dirty)

   # maintain frame rate
   clock.tick(30)

if __name__ == '__main__': main()
***

Now, there's just one problem, and I'm pretty sure you can see it:
After the program goes through all the strings, it doesn't stop at the
last one and tries to add one again. Which won't work, and the program
will print an error about it going out of bounds. I'm working on that
now, it should take no less than five or ten minutes to figure out.
Thanks for all your help!




Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-01-17 Thread Charles Christie

Good news everyone! I found out why I could never get anywhere:

I was too afraid of breaking stuff so I didn't try to mess with
anything. However, if you don't break it, how can you fix it? So, I
looked over that pygame thing again and decided to just start doing
things that came to mind. It took me five minutes to get it working,
much faster than if I had begged someone to tell me how to do it.
Python really is a simple language after all, I think I really
understand this now! This is what my code looks like now:

***
#Credit to scriptedfun (http://www.scriptedfun.com) for the help with
the typing portion
#Stil a very VERY barebones typing script. Still got one last part of the main
#engine to go before getting to work on part two.

import pygame
from pygame.locals import *

SCREENRECT = Rect(0, 0, 640, 480)

class Textsprite(pygame.sprite.Sprite):
   def __init__(self, text):
   pygame.sprite.Sprite.__init__(self)
   self.text = text
   self.pos = 0
   self.current_string = 0
   self.update()
   def update(self):
   self.image = pygame.font.Font(None,
36).render(self.text[self.current_string], 1, (0, 0, 0))
   self.highlight = pygame.font.Font(None,
36).render(self.text[self.current_string][:self.pos], 1, (0, 0, 255))
   self.image.blit(self.highlight, (0, 0))
   self.rect = self.image.get_rect()
   self.rect.center = pygame.display.get_surface().get_rect().center
   def keyin(self, key):
   if key == self.text[self.current_string][self.pos]:
   self.pos = self.pos + 1
   elif key == K_TAB:
   self.pos = self.pos
   else:
   self.combo = 0
   if len(self.text[self.current_string]) == self.pos:
   self.pos = 0
   self.current_string = self.current_string +1

def main():
   pygame.init()

   screen = pygame.display.set_mode(SCREENRECT.size)

   # make background
   background = pygame.Surface(SCREENRECT.size).convert()
   background.fill((255, 255, 255))
   screen.blit(background, (0, 0))
   pygame.display.update()

   # keep track of sprites
   all = pygame.sprite.RenderUpdates()

   # keep track of time
   clock = pygame.time.Clock()

   textsprite = Textsprite(["test string1", "another test!", "can you
type this?"])
   all.add(textsprite)

   # game loop
   while 1:

   # get input
   for event in pygame.event.get():
   if event.type == QUIT:
   return
   elif event.type == KEYDOWN:
   if event.key == K_ESCAPE:
   return
   else:
   textsprite.keyin(event.unicode)

   # clear sprites
   all.clear(screen, background)

   # update sprites
   all.update()

   # redraw sprites
   dirty = all.draw(screen)
   pygame.display.update(dirty)

   # maintain frame rate
   clock.tick(30)

if __name__ == '__main__': main()
***

Now, there's just one problem, and I'm pretty sure you can see it:
After the program goes through all the strings, it doesn't stop at the
last one and tries to add one again. Which won't work, and the program
will print an error about it going out of bounds. I'm working on that
now, it should take no less than five or ten minutes to figure out.
Thanks for all your help!


Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-01-16 Thread Farai Aschwanden

Hi

About Python with game programming I can recommend: http:// 
www.amazon.de/Programming-Python-Charles-Development-Paperback/dp/ 
1584502584
Erm, not for free but some general neat routine explanations as seen  
a lot in games.


Greetings
Farai


Am 16.01.2007 um 17:03 schrieb Charles Christie:


On 1/6/07, Kris Schnee <[EMAIL PROTECTED]> wrote:

> I think that you would benefit from buying and reading
> _Python Programming for the Absolute Beginner_ by
> Dawson.

I've had some success working through "Dive Into Python," a free
textbook available online at http://www.diveintopython.org/ .

> I kept ending up in the same part of code and denying that it
> was the right part, and then someone tells me its the right portion
> after all, which made me feel kinda... well... slow. >.<

No, "slow" would be refusing to see the problem _after_ having people
point it out. 8)

Kris



Wow, thanks for this! I've learned metric tons of info from it!

Well, I would've if info was measured in metric tons. ^_^




Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-01-16 Thread Charles Christie

On 1/6/07, Kris Schnee <[EMAIL PROTECTED]> wrote:

> I think that you would benefit from buying and reading
> _Python Programming for the Absolute Beginner_ by
> Dawson.

I've had some success working through "Dive Into Python," a free
textbook available online at http://www.diveintopython.org/ .

> I kept ending up in the same part of code and denying that it
> was the right part, and then someone tells me its the right portion
> after all, which made me feel kinda... well... slow. >.<

No, "slow" would be refusing to see the problem _after_ having people
point it out. 8)

Kris



Wow, thanks for this! I've learned metric tons of info from it!

Well, I would've if info was measured in metric tons. ^_^


Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-01-11 Thread Charles Christie

On 1/4/07, Brandon N <[EMAIL PROTECTED]> wrote:

I would be more concerned with ease of programming
than efficiency, as this is a pretty straightforward and non-
demanding application.



Are shoot-em-up games demanding? because I'm going to (much later)
add a shoot-em-up portion... that's not really important right now,
first things first!


You will also have to store the index of
the current string, and replace all references of self.text with it,
as in self.text[self.current_string]. Now, when the user completes a
string, you can increment self.current_string and reset self.pos and
the next string will be presented.

I'm currently in the __init__ part of my code... erm, the code that
someone helped me write
so what do I do with the line self.text = text? I think I have to just
leave that as is...
self.current_string has to equal something too. Unless, I've been
looking at this all wrong...
My other guess was that I have to change self.text = text to
self.text[self.current_string] = text, but that doesn't look quite
right to me.


I hope that this is helpful for you.


Very much so.


Cheers,
  Brandon


Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-01-06 Thread Kris Schnee

I think that you would benefit from buying and reading
_Python Programming for the Absolute Beginner_ by
Dawson.


I've had some success working through "Dive Into Python," a free 
textbook available online at http://www.diveintopython.org/ .



I kept ending up in the same part of code and denying that it
was the right part, and then someone tells me its the right portion
after all, which made me feel kinda... well... slow. >.<


No, "slow" would be refusing to see the problem _after_ having people 
point it out. 8)


Kris


Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-01-05 Thread Jason Marshall
Charles,

I think that you would benefit from buying and reading
_Python Programming for the Absolute Beginner_ by
Dawson. That book helped me to learn Python more than
any other resource. After I worked my way through it,
the other Python tutorials and documentation became
understandable to me too. My only criticism of the
book is that its later examples use pygame, but wrap
pygame inside of an obscure simplified library called
livewires; I would have preferred straight pygame
code.

(Before getting _Python Programming for the Absolute
Beginner_, I had tried _Learning Python_ by Lutz and
Ascher, but it was not what I needed. It doesn't
describe addition and subtraction until chapter 4!)

Jason M.

--- Charles Christie <[EMAIL PROTECTED]> wrote:

> I understood the python parts (except for class and
> def stuff, but I
> never understood that in any programming language),
> but it was
> isolating the part of the code that I wanted that
> confused me. I
> thought I had it (and I was right) but I
> second-guessed and looked
> around the rest of the code to find the typing part.
> The funny thing
> was that I kept ending up in the same part of code
> and denying that it
> was the right part, and then someone tells me its
> the right portion
> after all, which made me feel kinda... well... slow.
> >.< But I got it
> anyway... thanks for all your help!

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-01-05 Thread Charles Christie

I understood the python parts (except for class and def stuff, but I
never understood that in any programming language), but it was
isolating the part of the code that I wanted that confused me. I
thought I had it (and I was right) but I second-guessed and looked
around the rest of the code to find the typing part. The funny thing
was that I kept ending up in the same part of code and denying that it
was the right part, and then someone tells me its the right portion
after all, which made me feel kinda... well... slow. >.< But I got it
anyway... thanks for all your help!

On 1/4/07, Rikard Bosnjakovic <[EMAIL PROTECTED]> wrote:

On 1/5/07, Charles Joseph Christie II <[EMAIL PROTECTED]> wrote:

> Thanks for the replies, guys. I was afraid of using mailing lists
> because I thought I would get loads of "gtfo" and "noob" replies and,
> well, I never tried to figure out how they worked.

That's usually the case for www-forums and IRC. I seldom see monkey
wrench-comments like that on mailing lists. That's also a reason I
prefer ML before forums.

--
- Rikard.



Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-01-04 Thread Rikard Bosnjakovic

On 1/5/07, Charles Joseph Christie II <[EMAIL PROTECTED]> wrote:


Thanks for the replies, guys. I was afraid of using mailing lists
because I thought I would get loads of "gtfo" and "noob" replies and,
well, I never tried to figure out how they worked.


That's usually the case for www-forums and IRC. I seldom see monkey
wrench-comments like that on mailing lists. That's also a reason I
prefer ML before forums.

--
- Rikard.


Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-01-04 Thread Kai Kuehne

Sorry, forgot the smily:

On 1/5/07, Kai Kuehne <[EMAIL PROTECTED]> wrote:

Ok, knowing python could be useful to make a game in it.


;-)

Kai


Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-01-04 Thread Kai Kuehne

Hi,

On 1/5/07, Charles Joseph Christie II <[EMAIL PROTECTED]> wrote:

Saw that, but I didn't feel like getting ideas from other people's code
until I understood it myself. Oh yeah, and I couldn't make sense of
anything I read in that the first time I looked it over (I'd probably
get most of it now, but when I looked last time I didn't even know how
to get the typing portion, and I couldn't distinguish it from the rest
of the code :P ).


Ok, knowing python could be useful to make a game in it.


Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-01-04 Thread Luke Paireepinart

Charles Joseph Christie II wrote:

Saw that, but I didn't feel like getting ideas from other people's code
until I understood it myself. Oh yeah, and I couldn't make sense of
anything I read in that the first time I looked it over (I'd probably
get most of it now, but when I looked last time I didn't even know how
to get the typing portion, and I couldn't distinguish it from the rest
of the code :P ).
Thanks for the replies, guys. I was afraid of using mailing lists
because I thought I would get loads of "gtfo" and "noob" replies and,
well, I never tried to figure out how they worked. Thanks for not
outcasting me. You guys totally remind me of the Gentoo Linux forums
(which is a very good thing) so thanks again!
  
If you find you have any non-pygame-specific Python questions, the 
Python Tutor mailing list is very friendly also,

and there are some really knowledgeable people on that list.
You can subscribe to it from the python.org website.
Hope to see you there! :)
-Luke



Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-01-04 Thread Charles Joseph Christie II
Saw that, but I didn't feel like getting ideas from other people's code
until I understood it myself. Oh yeah, and I couldn't make sense of
anything I read in that the first time I looked it over (I'd probably
get most of it now, but when I looked last time I didn't even know how
to get the typing portion, and I couldn't distinguish it from the rest
of the code :P ).
Thanks for the replies, guys. I was afraid of using mailing lists
because I thought I would get loads of "gtfo" and "noob" replies and,
well, I never tried to figure out how they worked. Thanks for not
outcasting me. You guys totally remind me of the Gentoo Linux forums
(which is a very good thing) so thanks again!

On Fri, 5 Jan 2007 01:09:40 +0100
"Kai Kuehne" <[EMAIL PROTECTED]> wrote:

> Hi,
> 
> On 1/4/07, Charles Joseph Christie II <[EMAIL PROTECTED]> wrote:
> > Well, actually, after I finish all of the homework that's due
> > tomorrow. After I get this down, I just have to get the combo timer
> > system thing up... But I'll ask about that a little later. Thank
> > you!
> 
> Maybe you can find some "ideas" in TypusPocus:
> http://python.com.ar/juegos/TypusPocus
> 
> Greetings
> Kai


Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-01-04 Thread Kai Kuehne

Hi,

On 1/4/07, Charles Joseph Christie II <[EMAIL PROTECTED]> wrote:

Well, actually, after I finish all of the homework that's due tomorrow.
After I get this down, I just have to get the combo timer system thing
up... But I'll ask about that a little later. Thank you!


Maybe you can find some "ideas" in TypusPocus:
http://python.com.ar/juegos/TypusPocus

Greetings
Kai


Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-01-04 Thread Charles Joseph Christie II
YOU'RE AWESOME! Thank you, I was trying to figure out how to do it,
and after a while thought my idea was completely wrong... I owe you
one, I'll go and try this right now!

Well, actually, after I finish all of the homework that's due tomorrow.
After I get this down, I just have to get the combo timer system thing
up... But I'll ask about that a little later. Thank you!


On Thu, 4 Jan 2007 15:24:46 -0500
Brandon N <[EMAIL PROTECTED]> wrote:

> I will not give you the code since you have stated this in an  
> assignment, but hopefully I can help.
> 
> You are correct that you will need an array, or a list in Python, to  
> store the strings. I would be more concerned with ease of
> programming than efficiency, as this is a pretty straightforward and
> non- demanding application.
> 
> So, with that said, you will want your Textsprite class to take a  
> list of strings instead of just a string. You can do this by saying:
> 
> a = Textsprite(["test string1", "another test!", "can you type
> this?"])
> 
> Now, in your textsprite class, you have a variable that stores the  
> index of the current letter. You will also have to store the index
> of the current string, and replace all references of self.text with
> it, as in self.text[self.current_string]. Now, when the user
> completes a string, you can increment self.current_string and reset
> self.pos and the next string will be presented.
> 
> I hope that this is helpful for you.
> 
> Cheers,
>   Brandon
> 
> On Jan 4, 2007, at 2:45 PM, Charles Christie wrote:
> 
> > Hey, I am making a typing game in Python using pygame. I have  
> > finally hit a
> > roadblock, and I think I'm toast. I started this game as my senior  
> > project,
> > and I need to have something to at least demonstrate by June.
> >
> > I think I screwed myself on this one. I thought I knew a
> > reasonable amount of
> > programming, but absolutely none of it is coming in handy. I had
> > to ask for
> > help to get what I have now, and now I've hit a road block.
> >
> > So, what I need is:
> >
> > A. To find a way to feed multiple strings into the program. As in,  
> > when you
> > finish one string, instead of starting it over again you instead go
> > to the next word in the list, which I guessed should be an array of
> > strings. I'm probably wrong, though. What's the most efficient (or
> > easiest) way to do this?
> >
> > B. Two timers, a combo timer and a word timer that count backwards.
> > I know I can figure out how to do these myself, though.
> >
> > The code I have so far looks like this:
> > **
> > #Credit to scriptedfun (http://www.scriptedfun.com) for the help
> > #Stil a very VERY barebones typing script. Still got one last part  
> > of the main
> > #engine to go before getting to work on part two.
> >
> > import pygame
> > from pygame.locals import *
> >
> > SCREENRECT = Rect(0, 0, 640, 480)
> >
> > class Textsprite(pygame.sprite.Sprite):
> >def __init__(self, text):
> >pygame.sprite.Sprite.__init__(self)
> >self.text = text
> >self.pos = 0
> >self.update()
> >def update(self):
> >self.image = pygame.font.Font(None, 36).render(self.text,
> > 1, (0, 0, 0))
> >self.highlight = pygame.font.Font(None,
> > 36).render(self.text[:self.pos], 1, (0, 0, 255))
> >self.image.blit(self.highlight, (0, 0))
> >self.rect = self.image.get_rect()
> >self.rect.center = pygame.display.get_surface().get_rect 
> > ().center
> >def keyin(self, key):
> >if key == self.text[self.pos]:
> >self.pos = self.pos + 1
> >self.combo = self.combo + 1
> >else:
> >self.combo = 0
> >if len(self.text) == self.pos:
> >self.pos = 0
> >
> > def main():
> >pygame.init()
> >
> >screen = pygame.display.set_mode(SCREENRECT.size)
> >
> ># make background
> >background = pygame.Surface(SCREENRECT.size).convert()
> >background.fill((255, 255, 255))
> >screen.blit(background, (0, 0))
> >pygame.display.update()
> >
> ># keep track of sprites
> >all = pygame.sprite.RenderUpdates()
> >
> ># keep track of time
> >clock = pygame.time.Clock()
> >
> >textsprite = Textsprite('It works!')
> >all.add(textsprite)
> >
> ># game loop
> >while 1:
> >
> ># get input
> >for event in pygame.event.get():
> >if event.type == QUIT:
> >return
> >elif event.type == KEYDOWN:
> >if event.key == K_ESCAPE:
> >return
> >else:
> >textsprite.keyin(event.unicode)
> >
> ># clear sprites
> >all.clear(screen, background)
> >
> ># update sprites
> >all.update()
> >
> ># redraw sprites
> >dirty = all.draw(screen)
> >pygame.display.update(dirty)
> >
> ># maintain frame rate
> >clock.tick(3

Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-01-04 Thread Brandon N
I will not give you the code since you have stated this in an  
assignment, but hopefully I can help.


You are correct that you will need an array, or a list in Python, to  
store the strings. I would be more concerned with ease of programming  
than efficiency, as this is a pretty straightforward and non- 
demanding application.


So, with that said, you will want your Textsprite class to take a  
list of strings instead of just a string. You can do this by saying:


a = Textsprite(["test string1", "another test!", "can you type this?"])

Now, in your textsprite class, you have a variable that stores the  
index of the current letter. You will also have to store the index of  
the current string, and replace all references of self.text with it,  
as in self.text[self.current_string]. Now, when the user completes a  
string, you can increment self.current_string and reset self.pos and  
the next string will be presented.


I hope that this is helpful for you.

Cheers,
 Brandon

On Jan 4, 2007, at 2:45 PM, Charles Christie wrote:

Hey, I am making a typing game in Python using pygame. I have  
finally hit a
roadblock, and I think I'm toast. I started this game as my senior  
project,

and I need to have something to at least demonstrate by June.

I think I screwed myself on this one. I thought I knew a reasonable  
amount of
programming, but absolutely none of it is coming in handy. I had to  
ask for

help to get what I have now, and now I've hit a road block.

So, what I need is:

A. To find a way to feed multiple strings into the program. As in,  
when you

finish one string, instead of starting it over again you instead go to
the next word in the list, which I guessed should be an array of
strings. I'm probably wrong, though. What's the most efficient (or
easiest) way to do this?

B. Two timers, a combo timer and a word timer that count backwards. I
know I can figure out how to do these myself, though.

The code I have so far looks like this:
**
#Credit to scriptedfun (http://www.scriptedfun.com) for the help
#Stil a very VERY barebones typing script. Still got one last part  
of the main

#engine to go before getting to work on part two.

import pygame
from pygame.locals import *

SCREENRECT = Rect(0, 0, 640, 480)

class Textsprite(pygame.sprite.Sprite):
   def __init__(self, text):
   pygame.sprite.Sprite.__init__(self)
   self.text = text
   self.pos = 0
   self.update()
   def update(self):
   self.image = pygame.font.Font(None, 36).render(self.text, 1,  
(0, 0, 0))

   self.highlight = pygame.font.Font(None,
36).render(self.text[:self.pos], 1, (0, 0, 255))
   self.image.blit(self.highlight, (0, 0))
   self.rect = self.image.get_rect()
   self.rect.center = pygame.display.get_surface().get_rect 
().center

   def keyin(self, key):
   if key == self.text[self.pos]:
   self.pos = self.pos + 1
   self.combo = self.combo + 1
   else:
   self.combo = 0
   if len(self.text) == self.pos:
   self.pos = 0

def main():
   pygame.init()

   screen = pygame.display.set_mode(SCREENRECT.size)

   # make background
   background = pygame.Surface(SCREENRECT.size).convert()
   background.fill((255, 255, 255))
   screen.blit(background, (0, 0))
   pygame.display.update()

   # keep track of sprites
   all = pygame.sprite.RenderUpdates()

   # keep track of time
   clock = pygame.time.Clock()

   textsprite = Textsprite('It works!')
   all.add(textsprite)

   # game loop
   while 1:

   # get input
   for event in pygame.event.get():
   if event.type == QUIT:
   return
   elif event.type == KEYDOWN:
   if event.key == K_ESCAPE:
   return
   else:
   textsprite.keyin(event.unicode)

   # clear sprites
   all.clear(screen, background)

   # update sprites
   all.update()

   # redraw sprites
   dirty = all.draw(screen)
   pygame.display.update(dirty)

   # maintain frame rate
   clock.tick(30)

if __name__ == '__main__': main()
**

I've never used a mailing list before. I'm quite new at this. Sorry if
I disobeyed a rule of conduct or did something considered
implite/noobish/stupid.




[pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?

2007-01-04 Thread Charles Christie

Hey, I am making a typing game in Python using pygame. I have finally hit a
roadblock, and I think I'm toast. I started this game as my senior project,
and I need to have something to at least demonstrate by June.

I think I screwed myself on this one. I thought I knew a reasonable amount of
programming, but absolutely none of it is coming in handy. I had to ask for
help to get what I have now, and now I've hit a road block.

So, what I need is:

A. To find a way to feed multiple strings into the program. As in, when you
finish one string, instead of starting it over again you instead go to
the next word in the list, which I guessed should be an array of
strings. I'm probably wrong, though. What's the most efficient (or
easiest) way to do this?

B. Two timers, a combo timer and a word timer that count backwards. I
know I can figure out how to do these myself, though.

The code I have so far looks like this:
**
#Credit to scriptedfun (http://www.scriptedfun.com) for the help
#Stil a very VERY barebones typing script. Still got one last part of the main
#engine to go before getting to work on part two.

import pygame
from pygame.locals import *

SCREENRECT = Rect(0, 0, 640, 480)

class Textsprite(pygame.sprite.Sprite):
   def __init__(self, text):
   pygame.sprite.Sprite.__init__(self)
   self.text = text
   self.pos = 0
   self.update()
   def update(self):
   self.image = pygame.font.Font(None, 36).render(self.text, 1, (0, 0, 0))
   self.highlight = pygame.font.Font(None,
36).render(self.text[:self.pos], 1, (0, 0, 255))
   self.image.blit(self.highlight, (0, 0))
   self.rect = self.image.get_rect()
   self.rect.center = pygame.display.get_surface().get_rect().center
   def keyin(self, key):
   if key == self.text[self.pos]:
   self.pos = self.pos + 1
   self.combo = self.combo + 1
   else:
   self.combo = 0
   if len(self.text) == self.pos:
   self.pos = 0

def main():
   pygame.init()

   screen = pygame.display.set_mode(SCREENRECT.size)

   # make background
   background = pygame.Surface(SCREENRECT.size).convert()
   background.fill((255, 255, 255))
   screen.blit(background, (0, 0))
   pygame.display.update()

   # keep track of sprites
   all = pygame.sprite.RenderUpdates()

   # keep track of time
   clock = pygame.time.Clock()

   textsprite = Textsprite('It works!')
   all.add(textsprite)

   # game loop
   while 1:

   # get input
   for event in pygame.event.get():
   if event.type == QUIT:
   return
   elif event.type == KEYDOWN:
   if event.key == K_ESCAPE:
   return
   else:
   textsprite.keyin(event.unicode)

   # clear sprites
   all.clear(screen, background)

   # update sprites
   all.update()

   # redraw sprites
   dirty = all.draw(screen)
   pygame.display.update(dirty)

   # maintain frame rate
   clock.tick(30)

if __name__ == '__main__': main()
**

I've never used a mailing list before. I'm quite new at this. Sorry if
I disobeyed a rule of conduct or did something considered
implite/noobish/stupid.