forums.evilmana.com
Welcome, Guest. Please login or register.

Login with username, password and session length
September 10, 2010, 08:34:52 AM
.
News: 06/10/2009 - New Features For Forum.
Friendly URLs, twitter for profile, and video site URLs will auto-display the video.
Pages: [1]   Go Down
0 Members and 1 Guest are viewing this topic. Topic Tools  
Read June 19, 2007, 03:59:57 PM #0
error

stuck with fucntions

I just started reading into python yesterday. I thought a good place to start would be some tests to see how stuff works then try to rewrite the blockattack game I wrote in Lua in python. Long story short I am really stuck. One big problem I am having is how to control the flow of things and just how can I use a function like I am use to with Lua? In this case for the blockattack example I used some if statements and functions to setup a state machine so I could control what was going on. Understanding how functions and classes work in python is giving me a headache. Any pointers?
Offline  
Read June 19, 2007, 04:11:53 PM #1
bronxbomber92

Re: stuck with fucntions

They're pretty much the same.. Any specific examples? Like what you have in Lua, and what you currently have in Python.
Offline  
Read June 19, 2007, 04:41:37 PM #2
error

Re: stuck with fucntions

I dont know how much of what was in the Lua version I want to keep the same. For arguments sake here is the function that rendered the splash screens for the dc emu grand prix.

Code:
function logoState()

if startlogotimer == 1 then --a do once do start the timer
mahTimer:start()
startlogotimer = 0
end

logoTimer = mahTimer:time()

if logoTimer < 1000 then
screen:blit(124, 6, logo1)
end

if logoTimer > 2000 and logoTimer < 4000 then
screen:blit(124, 105, logo2)
screen:print(154, 180, "http://www.hwhq.com/", red)
end

if logoTimer > 6000 then
mahTimer:reset(0)
mahTimer:stop()
currentState = 2
end
end

hope this portion of code doesnt look horrible.

edit: im starting to get an idea of how it works. i just realized that one little section of lua that is ever so simple is going to be a nightmare. im trying to learn how sprites and timers work to get this started. i guess the good part is once i get this little and very pointless part done I will know enough about sprites to continue on.
« Last Edit: June 19, 2007, 05:47:25 PM by error »
Offline  
Read June 19, 2007, 07:05:26 PM #3
bronxbomber92

Re: stuck with fucntions

Are you using Pygame? I don't know the Python built in functions (so I don't know how to setup a timer, or any of its math functions, ect...), but it sounds like you're having a problem with Python's syntax, so that above function would be along the lines of...
Code:
def logoState():
    if startlogotimer == 1:
        # start time
        startlogotimer = 0
   
    # ect
Remember, indentation is crucial in Python, scope depends on it. I may be able to help you a bit more if I knew what you're using for drawing graphics Smile
Offline  
Read June 19, 2007, 07:15:16 PM #4
error

Re: stuck with fucntions

ya I have pygame working. I read through some tutorials on devshed for sprite usage. I think I can manage now it will just take some time to write it out. For this function I am just bliting 2 pngs for a second each then changing states.
Offline  
Pages: [1]   Go Up
Jump to:  

Theme Update by Runic Warrior Originally created by m3talc0re