[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Declaring variables in function as if at code's line-level



Someone really needs to turn this thread into a game...



On Tue, Mar 13, 2012 at 5:34 PM, Brian Brown <brobab@xxxxxxxxx> wrote:

I started QBasic at about 12. . .
I am nearly completely "self-taught" and 
I started making my ball program in Java at about 14-- I carefully thought out the algorithms by myself-- Because I couldn't find code about how to make balls accurately bounce off walls --at any speed without glitches.

Yeah, I see what you mean, Chris, "global" is not necessary when: all the variables are created outside of all the functions-- I  did  know that but-- I just wanted to create or delete any variables from within a function-- which can be called whenever from wherever-- so I could easily control/manipulate the memory consumption and variable usage.
(Well whatever, I'll find a way I guess.)

I admit, it was really dumb to force my opinion on all of you.
(I was  Not  planning on saying what I did-- but it just wasn't my day. (if you know what I mean) I thought I would just ask one simple question and get the answer. lol But I accidentally let my frustration show in my replies. So stupid of me.)

Anyways, I think I should just continue being a solo programmer.
lol I'm too wild when it comes to programming that I think I need "my own space." If you know what I mean.

stress_relieving_variable = 'Five-Hundred and Forty-Three Lily Hopping Ponies All Cooking Savory Spaghetti'
dont_print(stress_relieving_variable)

# Shshsh! Don't let anyone know I gave you
# The ultimate key to game programming!
# (Don't share it with anyone else, because
# they will only want it for themselves! >:3 )

lolol!

Thanks again for all your replies, suggestions, and the links. ; )
And sorry for making such a big scene--
I must do some chores.

Goodbye.
(You may abandon the thread.)

Sincerely, Matthew


On Tue, Mar 13, 2012 at 3:21 PM, Daniel Pope <mauve@xxxxxxxxxxxxxx> wrote:
On Mon, Mar 12, 2012 at 12:27:39PM -0700, Brian Brown wrote:
> Matthew N. Brown

I googled. I guess this is yours?

http://pastebin.com/kKXSgw8c

> It's like    "pygame.draw.line()"   instead of just: "DRAW_LINE()"

It's because of fallacies like this that your program would be
completely unmaintainable for anyone other than you.

Classes and modules allow us to break our code into separate concerns
that other programmers can pick up and understand immediately (as can we
when we come back to something having forgotten what we wrote).

They also tend to allow massive amounts of code re-use. If you wrote
only a proper 2D vector class (or downloaded one [1]) I reckon you could
halve the amount of code you had to write for your bouncing balls
program.

To help you out, here is the A Byte of Python chapter about Object
Oriented Programming (ie. classes):

http://www.swaroopch.com/notes/Python_en:Object_Oriented_Programming

[1] http://www.supereffective.org/pages/Vector-2d-Vector-Library