Re: pygame knowing if window is in keyboard focus or no?

2021-01-14 Thread AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector


  


Re: pygame knowing if window is in keyboard focus or no?

As post two indicated:https://www.pygame.org/docs/ref/display.html

URL: https://forum.audiogames.net/post/606845/#p606845




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: pygame knowing if window is in keyboard focus or no?

2021-01-14 Thread AudioGames . net Forum — Developers room : Hijacker via Audiogames-reflector


  


Re: pygame knowing if window is in keyboard focus or no?

Keep track of the pygame ACTIVEEVENT to find out.

URL: https://forum.audiogames.net/post/606840/#p606840




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: pygame knowing if window is in keyboard focus or no?

2021-01-14 Thread AudioGames . net Forum — Developers room : pauliyobo via Audiogames-reflector


  


Re: pygame knowing if window is in keyboard focus or no?

Perhapps you're looking for pygame.display.get_active()

URL: https://forum.audiogames.net/post/606785/#p606785




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


pygame knowing if window is in keyboard focus or no?

2021-01-14 Thread AudioGames . net Forum — Developers room : mohamed via Audiogames-reflector


  


pygame knowing if window is in keyboard focus or no?

hi, So i want to get is the window in the keyboard focus to let the thing do some tasks if it's not in the keyboard focus, So is there anyway to do this?

URL: https://forum.audiogames.net/post/606765/#p606765




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: letting pygame accept key presses regardless of the keybored language?

2020-12-26 Thread AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector


  


Re: letting pygame accept key presses regardless of the keybored language?

Pygame uses events for keys being pressed or released. Lucia catches these and tracks them so you can use BGT's polling functions. That means that Lucia either tracks the state of arbitrary keys, or it only tracks the defined keycodes.I'd ignore it entirely and use the events directly, but Lucia probably clears the event queue when updating.The events give the keycode, which does not necessarily have to correspond to any particular defined constant. I'm not sure of a better way to identify which key is being pressed than with a configuration routine, though. I suppose the upside would be that it means the controls can be configured however the player wants?

URL: https://forum.audiogames.net/post/602320/#p602320




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: letting pygame accept key presses regardless of the keybored language?

2020-12-26 Thread AudioGames . net Forum — Developers room : mohamed via Audiogames-reflector


  


Re: letting pygame accept key presses regardless of the keybored language?

oh, I thought that lucia just wraps the pygame stuff in a other easy way for bgt people to use because it's a bit of the same, That's why i refered at it as pygame, I didn't knew that lucia is the problem.

URL: https://forum.audiogames.net/post/602176/#p602176




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: letting pygame accept key presses regardless of the keybored language?

2020-12-26 Thread AudioGames . net Forum — Developers room : Turret via Audiogames-reflector


  


Re: letting pygame accept key presses regardless of the keybored language?

Yup. You'd have to rewrite the key handling basically from scratch. Which let's be honest, would actually be good (Lucia's key handling is a pile of shit), but still. Not worth it IMHO.

URL: https://forum.audiogames.net/post/602121/#p602121




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: letting pygame accept key presses regardless of the keybored language?

2020-12-26 Thread AudioGames . net Forum — Developers room : mohamed via Audiogames-reflector


  


Re: letting pygame accept key presses regardless of the keybored language?

arabic isn't only the matter, Lets say i made a game where it has chat, Arabic isn't the only language that uses stuff like that, So other people will have the problem as well who doesn't use english characters.

URL: https://forum.audiogames.net/post/602111/#p602111




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: letting pygame accept key presses regardless of the keybored language?

2020-12-26 Thread AudioGames . net Forum — Developers room : bhanuponguru via Audiogames-reflector


  


Re: letting pygame accept key presses regardless of the keybored language?

google the keycodes for arabic keyboard and use the keycode instead of lucia.K_COMMA. i think it works

URL: https://forum.audiogames.net/post/602104/#p602104




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: letting pygame accept key presses regardless of the keybored language?

2020-12-26 Thread AudioGames . net Forum — Developers room : Turret via Audiogames-reflector


  


Re: letting pygame accept key presses regardless of the keybored language?

Without rewriting the hole key handling system, I don't think you can do this. Lucia only supports English chars.

URL: https://forum.audiogames.net/post/602073/#p602073




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: letting pygame accept key presses regardless of the keybored language?

2020-12-26 Thread AudioGames . net Forum — Developers room : mohamed via Audiogames-reflector


  


Re: letting pygame accept key presses regardless of the keybored language?

i don't know, But when i let it do something like#note, Lucia uses pygame key presses.if lucia.key_pressed(lucia.K_COMMA):  speak("test.")when i press the place where comma is found on my keyboard but while the keyboard is arabic, The thing doesn't do anything at all.

URL: https://forum.audiogames.net/post/602072/#p602072




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: letting pygame accept key presses regardless of the keybored language?

2020-12-26 Thread AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector


  


Re: letting pygame accept key presses regardless of the keybored language?

Do you still get a key code, or does it just not fire an event at all?

URL: https://forum.audiogames.net/post/602065/#p602065




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


letting pygame accept key presses regardless of the keybored language?

2020-12-26 Thread AudioGames . net Forum — Developers room : mohamed via Audiogames-reflector


  


letting pygame accept key presses regardless of the keybored language?

hi, So using lucia with pygame, Having a small problem though, When i switch the keyboard language to none english, Key presses aren't accepted, They just doesn't do anything, So to use them i need to return to english, That could be annoying if am for exampal chatting or something so is there anyway to let pygame accept key presses regardless of the keyboard language?also, Keys like f1, f2, 1, 2 are fine, But keys like a, dot, comma, etc aren't accepted

URL: https://forum.audiogames.net/post/602055/#p602055




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


letting pygame accept key presses regardless of the keybored language?

2020-12-26 Thread AudioGames . net Forum — Developers room : mohamed via Audiogames-reflector


  


letting pygame accept key presses regardless of the keybored language?

hi, So using lucia with pygame, Having a small problem though, When i switch the keyboard language to none english, Key presses aren't accepted, They just doesn't do anything, So to use them i need to return to english, That could be annoying if am for exampal chatting or something so is there anyway to let pygame accept key presses regardless of the keyboard language?

URL: https://forum.audiogames.net/post/602055/#p602055




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Pyglet VS Pygame?

2020-09-16 Thread AudioGames . net Forum — Developers room : chrisnorman7 via Audiogames-reflector


  


Re: Pyglet VS Pygame?

I like that Pyglet doesn't require you to write your own event loop. It feels nicer to write with for myself, and there's none of this "pyglet.whatever.init" the whole time.

URL: https://forum.audiogames.net/post/571269/#p571269




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Pyglet VS Pygame?

2020-09-12 Thread AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector


  


Re: Pyglet VS Pygame?

Pyglet is built with OpenGL in the backend, so it has better rendering support for heavy lifting or 3D applications/shaders. Of course, that may not necessarily be applicable to audiogames perse, though there are some potential applications that could be useful for, such as sonifiers. Pygames audio is also a bit more basic, whereas Pyglet has 3D positional and basic OpenAL support which can admittedly be expanded, though there are third party libraries and scripts that may work just as well or better out of the box. It does seem to have an easier time dealing with certain audio formats though.

URL: https://forum.audiogames.net/post/570167/#p570167




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Pyglet VS Pygame?

2020-09-12 Thread AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector


  


Re: Pyglet VS Pygame?

Pyglet is built with OpenGL in the backend, so it has better rendering support for heavy lifting or 3D applications/shaders. Of course, that may not necessarily be applicable to audiogames perse, though there are some potential applications that could be useful for, such as sonifiers. Pygames audio is also a bit more basic, whereas Pyglet has 3D positional and basic OpenAL support which can admittedly be expanded, though there are third party libraries and scripts that can work just as well or better out of the box.For most applications that aren't graphically intensive you may not find any appreciable difference between the two, especially if you use a third party audio library.

URL: https://forum.audiogames.net/post/570167/#p570167




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Pyglet VS Pygame?

2020-09-12 Thread AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector


  


Re: Pyglet VS Pygame?

Pyglet is built with OpenGL in the backend, so it has better rendering support for heavy lifting. Of course, that may not necessarily be applicable to audiogames perse, though there are some potential applications that could be useful for, such as sonifiers. Pygames audio is also a bit more basic, whereas Pyglet has 3D positional and basic OpenAL support which can admittedly be expanded, though there are third party libraries and scripts that can work just as well or better out of the box.For most applications that aren't graphically intensive you may not find any appreciable difference between the two, especially if you use a third party audio library.

URL: https://forum.audiogames.net/post/570167/#p570167




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Pyglet VS Pygame?

2020-09-12 Thread AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector


  


Re: Pyglet VS Pygame?

Nothing that I couldn't write myself in half an hour total.  It's got a somewhat useful event system, but it's not ahrd to write a somewhat useful event system when you need one, and the other features are generally not applicable to us.

URL: https://forum.audiogames.net/post/570158/#p570158




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Pyglet VS Pygame?

2020-09-12 Thread AudioGames . net Forum — Developers room : ironcross32 via Audiogames-reflector


  


Re: Pyglet VS Pygame?

I loathe Pyglet. Pygame is much better IMO.

URL: https://forum.audiogames.net/post/570152/#p570152




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Pyglet VS Pygame?

2020-09-12 Thread AudioGames . net Forum — Developers room : Ty via Audiogames-reflector


  


Pyglet VS Pygame?

I've seen a lot of people talking about Pyglet. Are there any advantages of it over pygame, which i'm used to?

URL: https://forum.audiogames.net/post/570113/#p570113




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Pygame and graphics?

2020-09-08 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


Re: Pygame and graphics?

this isn't completely graphics, but I found an input class that works kind of like lucia's virtual input module. It has some options to adjust font, color, and it has a visible cursor. I modified this module to work with lucia so that blind people can use it. It's not perfect, but at least it has some visual element to it.

URL: https://forum.audiogames.net/post/568480/#p568480




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Pygame Tutorials

2020-09-07 Thread AudioGames . net Forum — Developers room : bhanuponguru via Audiogames-reflector


  


Re: Pygame Tutorials

hiin place of accessibility, you need to use a speech library. you must figure out to create a menu wihch returns the object where you pressed enter. once, if you wan't, look at americranian's guide. it's cool. there, he explains every thing about accessibility. any way, it depends on your logical thinking.

URL: https://forum.audiogames.net/post/567990/#p567990




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Pygame and graphics?

2020-09-06 Thread AudioGames . net Forum — Developers room : Phoenix009 via Audiogames-reflector


  


Re: Pygame and graphics?

HiThose helped. Thanks a ton!

URL: https://forum.audiogames.net/post/567952/#p567952




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Pygame Tutorials

2020-09-06 Thread AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector


  


Re: Pygame Tutorials

Pygame by itself isn't terribly accessible, so you'd need to hook in your own TTS support via Tolk, Accessible_output2, pyttsx, etc. Or do pre-recorded speech. I've posted a number of basic examples for pygame before, like [here], [here], or [here], along with descriptions for rudimentary GUI development using geometry like [here].If you have any specific questions, feel free to ask.

URL: https://forum.audiogames.net/post/567933/#p567933




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Pygame Tutorials

2020-09-06 Thread AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector


  


Re: Pygame Tutorials

Pygame by itself isn't terribly accessible, so you'd need to hook in your own TTS support via Tolk, Accessible_output2, pyttsx, etc. Or do pre-recorded speech. I've posted a number of basic examples for pygame before, like [here], [here], or [here], along with descriptions for rudimentary GUI development using geometry.If you have any specific questions, feel free to ask.

URL: https://forum.audiogames.net/post/567933/#p567933




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Pygame Tutorials

2020-09-06 Thread AudioGames . net Forum — Developers room : Phoenix009 via Audiogames-reflector


  


Re: Pygame Tutorials

HiI learned a few topics from the articles room, but I want to move on from that. However, when I looked through google search, I couldn't find much for accessible game for the blind development in pygame.

URL: https://forum.audiogames.net/post/567929/#p567929




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Pygame Tutorials

2020-09-06 Thread AudioGames . net Forum — Developers room : Turkce_Rap via Audiogames-reflector


  


Re: Pygame Tutorials

See the articles room, it exists there.

URL: https://forum.audiogames.net/post/567825/#p567825




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Pygame Tutorials

2020-09-06 Thread AudioGames . net Forum — Developers room : Phoenix009 via Audiogames-reflector


  


Pygame Tutorials

Hi GuysI want to build games using pygame.However, I am not able to find some good tutorials, especially for gui's. I did look at nathantech, but didn't understand much.Could someone suggest some tutorials made for the blind that can help me learn pygame?Note: I already know python.Thanks in advance for any help I might get.

URL: https://forum.audiogames.net/post/567595/#p567595




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Fixed angle graphics, Pygame, and some more limitations...

2020-02-19 Thread AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector


  


Re: Fixed angle graphics, Pygame, and some more limitations...

Bleh, I should play around with this a bit more, but here's an example using a perspective view at a fixed 45 degree angle, as opposed to an orthographic view. The quad surfaces are viewable only from the front, though I have another example using cube models that uses PySTL I can also throw in. Use the arrow keys to pan the camera around, you can also adjust the color or alpha transparency of the quads trivially by adjusting the color bits of each vertex in the vertex lists. I can also put together another one for applying textures.import pyglet
pyglet.options['shadow_window'] = False
from pyglet.gl import *
from pyglet.window import key
import math

class Example(pyglet.window.Window):
def __init__(self):
super(Example, self).__init__(640, 480, resizable=True, fullscreen=False, caption="Example")
self.clear()

#Enable blending
gl.glEnable(GL_BLEND)
gl.glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)

#Enable transparency
glEnable(GL_ALPHA_TEST)
glAlphaFunc(GL_GREATER, .1)

self.render = pyglet.graphics.Batch()

self.images = []

#quad 1
x,y,z = -0,-65,64
self.images.append(self.render.add(4, pyglet.gl.GL_QUADS, None,#group(1),
('v3f',((x),(y),z, 32+(x),(y),z/2, 32+(x),32+(y),z/2, (x),32+(y),z)),
('c4B',(255,255,255,255)*4)))
#quad 2
x,y,z = -32,-65,96
self.images.append(self.render.add(4, pyglet.gl.GL_QUADS, None,#group(1),
('v3f',((x),(y),z, 32+(x),(y),z-32, 32+(x),32+(y),z-32, (x),32+(y),z)),
('c4B',(255,255,255,255)*4)))
#quad 3
x,y,z = -64,-65,64
self.images.append(self.render.add(4, pyglet.gl.GL_QUADS, None,#group(1),
('v3f',((x),(y),z, 32+(x),(y),z+32, 32+(x),32+(y),z+32, (x),32+(y),z)),
('c4B',(255,255,255,255)*4)))

#change first textures color to red and make it semi transparent
self.images[0].colors = (255,0,0,128)*4

self.position = [0,0,-140]
self.rotation = [0,-45]

#up, down, left, right
self.scroll = [False,False,False,False]

self.key_input = []

glEnable(GL_DEPTH_TEST)

glEnable(GL_CULL_FACE)

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)

setup_fog()


pyglet.clock.get_fps()
self.fps_display = pyglet.clock.ClockDisplay()
pyglet.clock.schedule_interval(self.update, .01)


def update(self,dt):
if 'UP release' in self.key_input:
self.scroll[0] = False
elif 'UP press' in self.key_input:
self.scroll[0] = True
if 'DOWN release' in self.key_input:
self.scroll[1] = False
elif 'DOWN press' in self.key_input:
self.scroll[1] = True
if 'LEFT release' in self.key_input:
self.scroll[2] = False
elif 'LEFT press' in self.key_input:
self.scroll[2] = True
if 'RIGHT release' in self.key_input:
self.scroll[3] = False
elif 'RIGHT press' in self.key_input:
self.scroll[3] = True

if self.scroll[0] == True:
self.position[2] += 1
if self.scroll[1] == True:
self.position[2] -= 1
if self.scroll[2] == True:
self.position[0] -= 1
if self.scroll[3] == True:
self.position[0] += 1

if len(self.key_input) > 0:
self.key_input = []

self.draw()


def on_key_press(self,symbol,modifiers):
self.key_input.append(key.symbol_string(symbol) + " press")
print key.symbol_string(symbol) + " press"

if symbol == key.ESCAPE:
self.close()


def on_key_release(self,symbol,modifiers):
self.key_input.append(key.symbol_string(symbol) + " release")
print key.symbol_string(symbol) + " release"


def draw(self):
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
gluPerspective(65.0, self.width / float(self.height), 10.0, 1000.0) #near/far clipping planes

glMatrixMode(GL_MODELVIEW)
glLoadIdentity()
#rotation view
x, y = self.rotation
glRotatef(x, 0, 1, 0)
glRotatef(-y, math.cos(math.radians(x)), 0, math.sin(math.radians(x)))
#movement view
x, y, z = self.position
glTranslatef(x, -y, z)

#initialize depth buffer
glClear(GL_DEPTH_BUFFER_BIT)
glEnable(GL_DEPTH_TEST)

#bind textures for rendering batch(s)
self.render.draw()

#disable depth buffer
glDisable(GL_DEPTH_TEST)
glColor4f(1, 1, 1, 1)

glLoadIdentity()
self.fps_display.draw()

def setup_fog():
"&qu

Re: Fixed angle graphics, Pygame, and some more limitations...

2020-02-18 Thread AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector


  


Re: Fixed angle graphics, Pygame, and some more limitations...

Bleh, I should play around with this a bit more, but here's an example using a perspective view at a fixed 45 degree angle, as opposed to an orthographic view. The quad surfaces are viewable only from the front, though I have another example using cube models that uses PySTL I can also throw in. Use the arrow keys to pan the camera around, you can also adjust the color or alpha transparency of the quads trivially by adjusting the color bits of each vertex in the vertex lists. I can also put together another one for applying textures.import pyglet
pyglet.options['shadow_window'] = False
from pyglet.gl import *
from pyglet.window import key
import math

class Example(pyglet.window.Window):
def __init__(self):
super(Example, self).__init__(640, 480, resizable=True, fullscreen=False, caption="Example")
self.clear()

#Enable blending
gl.glEnable(GL_BLEND)
gl.glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)

#Enable transparency
glEnable(GL_ALPHA_TEST)
glAlphaFunc(GL_GREATER, .1)

self.render = pyglet.graphics.Batch()

self.images = []

#quad 1
x,y,z = -0,-65,64
self.images.append(self.render.add(4, pyglet.gl.GL_QUADS, None,#group(1),
('v3f',((x),(y),z, 32+(x),(y),z/2, 32+(x),32+(y),z/2, (x),32+(y),z)),
('c4B',(255,255,255,255)*4)))
#quad 2
x,y,z = -32,-65,96
self.images.append(self.render.add(4, pyglet.gl.GL_QUADS, None,#group(1),
('v3f',((x),(y),z, 32+(x),(y),z-32, 32+(x),32+(y),z-32, (x),32+(y),z)),
('c4B',(255,255,255,255)*4)))
#quad 3
x,y,z = -64,-65,64
self.images.append(self.render.add(4, pyglet.gl.GL_QUADS, None,#group(1),
('v3f',((x),(y),z, 32+(x),(y),z+32, 32+(x),32+(y),z+32, (x),32+(y),z)),
('c4B',(255,255,255,255)*4)))

#change first textures color to red and make it semi transparent
self.images[0].colors = (255,0,0,128)*4

self.position = [0,0,-140]
self.rotation = [0,-45]

#up, down, left, right
self.scroll = [False,False,False,False]

self.key_input = []

glEnable(GL_DEPTH_TEST)

glEnable(GL_CULL_FACE)

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)

setup_fog()


pyglet.clock.get_fps()
self.fps_display = pyglet.clock.ClockDisplay()
pyglet.clock.schedule_interval(self.update, .01)


def update(self,dt):
if 'UP release' in self.key_input:
self.scroll[0] = False
elif 'UP press' in self.key_input:
self.scroll[0] = True
if 'DOWN release' in self.key_input:
self.scroll[1] = False
elif 'DOWN press' in self.key_input:
self.scroll[1] = True
if 'LEFT release' in self.key_input:
self.scroll[2] = False
elif 'LEFT press' in self.key_input:
self.scroll[2] = True
if 'RIGHT release' in self.key_input:
self.scroll[3] = False
elif 'RIGHT press' in self.key_input:
self.scroll[3] = True

if self.scroll[0] == True:
self.position[2] += 1
if self.scroll[1] == True:
self.position[2] -= 1
if self.scroll[2] == True:
self.position[0] -= 1
if self.scroll[3] == True:
self.position[0] += 1

if len(self.key_input) > 0:
self.key_input = []

self.draw()


def on_key_press(self,symbol,modifiers):
self.key_input.append(key.symbol_string(symbol) + " press")
print key.symbol_string(symbol) + " press"

if symbol == key.ESCAPE:
self.close()


def on_key_release(self,symbol,modifiers):
self.key_input.append(key.symbol_string(symbol) + " release")
print key.symbol_string(symbol) + " release"


def draw(self):
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
gluPerspective(65.0, self.width / float(self.height), 10.0, 1000.0) #near/far clipping planes

glMatrixMode(GL_MODELVIEW)
glLoadIdentity()
#rotation view
x, y = self.rotation
glRotatef(x, 0, 1, 0)
glRotatef(-y, math.cos(math.radians(x)), 0, math.sin(math.radians(x)))
#movement view
x, y, z = self.position
glTranslatef(x, -y, z)

#initialize depth buffer
glClear(GL_DEPTH_BUFFER_BIT)
glEnable(GL_DEPTH_TEST)

#bind textures for rendering batch(s)
self.render.draw()

#disable depth buffer
glDisable(GL_DEPTH_TEST)
glColor4f(1, 1, 1, 1)

glLoadIdentity()
self.fps_display.draw()

def setup_fog():
"&qu

Re: Fixed angle graphics, Pygame, and some more limitations...

2020-02-05 Thread AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector


  


Re: Fixed angle graphics, Pygame, and some more limitations...

Making walls semitransparent seems both distracting and computationally expensive. Were it the kind of setting where windows or holes would make sense, that'd be simpler, and I do expect that to be the most common category (railings, trees, rock formations).The proposed example would be appreciated.

URL: https://forum.audiogames.net/post/498739/#p498739




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Fixed angle graphics, Pygame, and some more limitations...

2020-02-04 Thread AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector


  


Re: Fixed angle graphics, Pygame, and some more limitations...

Ah ok, that makes things a bit easier. I'd planned on working on a 2D isometric game ages ago, handling Z depth range was going to be handled mostly with rendering order, though if your going with a fixed camera angle over a 3D scene then you won't have to worry much about Z placement. I can throw together an example demonstrating a renderer for a 3D isometric perspective with Pyglet if you like, I keep a few batch rendering examples on hand I can work with, though may need a bit to staple together the camera perspective.As a side note, in other isometric games they handle players being obscured behind walls by making the walls semi-transparent with alpha blending.

URL: https://forum.audiogames.net/post/498710/#p498710




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Fixed angle graphics, Pygame, and some more limitations...

2020-02-03 Thread AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector


  


Re: Fixed angle graphics, Pygame, and some more limitations...

More or less, if I understand correctly.

URL: https://forum.audiogames.net/post/498462/#p498462




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Fixed angle graphics, Pygame, and some more limitations...

2020-02-03 Thread AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector


  


Re: Fixed angle graphics, Pygame, and some more limitations...

Traditionally pygame wasn't as good at dealing with 3D as Pyglet is, though this may have changed with Pygame 2. With pyglet you can use batch rendered vertex lists for much better performance, I can end up rendering 1500+ textured quads for example, and you can adjust the camera angle by messing with a few lower level OpenGL commands. Is the perspective of this going to be Isometric with 3D?

URL: https://forum.audiogames.net/post/498415/#p498415




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Fixed angle graphics, Pygame, and some more limitations...

2020-01-30 Thread AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector


  


Fixed angle graphics, Pygame, and some more limitations...

I kinda wanted to do a Sega Genesis game, but I have yet to figure out how to fix my early text-games that used JS and new Array, so clearly ASM or a C compiler for ASM are beyond my attention span.So I'm using Pygame, but trying to acknowledge the limitations of the Genesis when it wouldn't be too cumbersome (ex, I can limit the number of sounds playing, but it'd be pointless to convert all sounds to the right format, for the time being. Since I don't have sprites, though, limiting colors to 4 palettes of 16, being careful with data structures, etc are all viable.)Anyway, it's supposed to be 3d, which for these limitations, means we need a fixed angle. (The audio will probably just be top-down, but I could put in a cabinet mode at some point for the fun of it?). And then come all the difficulties that come with drawing such things.Right now, I have three main issues:1. Z indexing. Particularly, since I don't have sprites, I was going to try and use what amount to stick-figures, except the torso and head involve polygons. Not shooting for any awards, and it's not like anyone who might see it would expect Great Art. The trouble with this is that individual bodyparts are going to overlap others. What I've got now is to create a list of callbacks and sort them, and that seems like a really terrible idea. Is there not a better solution than treating each bodypart as a separate object?2. The wall problem. If a player is beside a wall, on one side of the wall, they will be hidden behind it. There isn't a fixed angle where we can see walls from left or right and not have it cover things up. I'm tempted to just draw boxes from two opposite angles anyway, but that'd inevitably cause people to walk through what looks like a solid object. I don't necessarily need all rooms to be like /__\, but /__/ covers up the southeast corner. I'm not sure if it's practical to design all maps in such a way as to make it impossible to get close to long walls from one direction, or for every case of needing to see the side and top to always happen from the same direction.3. Patterns, tiles, textures. The Genesis is built on 8x8 tiles, so tiling an area in patterns is fast and easy. Pygame ... I could use for loops to tile a surface with another surface, but I'm going to be drawing lots of not-necessarily-rectangular quadrilaterals, and while I suspect that 1996!me would be fine with solid-color shapes, it'd be nice to get some texturing involved, even if it's just a few stripes or splotches that repeat. This gets worse with barriers that can be seen through, like behind a fence. Is there a fast way to do something like that?I'm trying for object-based maps, rather than tile-based. This means I need to seriously limit the number of objects in a single area, and use whatever tricks I can to speed up hit detection and drawing. I've noticed that some maps that should not be broken apart nonetheless have distinct subregions, which can be rounded off to halves or quadrants so I don't have to try and implement graphs with Genesis limitations. And I am trying to use simple datastructures to make objects more complex without as much of a footprint, like paths made up of a list of verteces with a low maximum vertex count. But then I have to figure out how to draw those, and we hit the above problems.(Having only 64 colors allowed on screen at a time is going to be interesting, I can already tell. I think I need a whole 2 palettes for characters, and might be able to squeeze items and animals into another, leaving just one for scenery. I almost want to break things up into smaller maps just to simplify that.)

URL: https://forum.audiogames.net/post/497226/#p497226




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Pygame problem

2019-12-11 Thread AudioGames . net Forum — Developers room : ashleygrobler04 via Audiogames-reflector


  


Re: Pygame problem

oh yeah. i know that you need to print out to the consoll and then only it will speak. haha for a moment i thought i missed some thing. thanks for letting me know'

URL: https://forum.audiogames.net/post/484698/#p484698




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Pygame problem

2019-12-11 Thread AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector


  


Re: Pygame problem

No, text displays in a pygame window are not accessible. The print function in question prints text to the console window. To get TTS output with pygame or pyglet you'll need a TTS library like Tolk.

URL: https://forum.audiogames.net/post/484648/#p484648




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Pygame problem

2019-12-11 Thread AudioGames . net Forum — Developers room : ashleygrobler04 via Audiogames-reflector


  


Re: Pygame problem

wow does printing on a pygame window actually work? i meen does NVDA speak what's printed while a pygame window is open?

URL: https://forum.audiogames.net/post/484631/#p484631




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Pygame problem

2019-12-07 Thread AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector


  


Re: Pygame problem

The menu does not provide any feedback. This is intentional as you will see in the comments. By not providing the code for speaking and audio I allowed anybody to use the class with any speech and sound libraries.

URL: https://forum.audiogames.net/post/483676/#p483676




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Pygame or PyQt which Gui?

2019-12-07 Thread AudioGames . net Forum — Developers room : Turkce_Rap via Audiogames-reflector


  


Re: Pygame or PyQt which Gui?

This topic has inlightent me a lot. Let's go on  non gaming projects.

URL: https://forum.audiogames.net/post/483247/#p483247




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Pygame problem

2019-12-07 Thread AudioGames . net Forum — Developers room : Turkce_Rap via Audiogames-reflector


  


Re: Pygame problem

@7That's  helpfull thank You.

URL: https://forum.audiogames.net/post/483497/#p483497




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Pygame problem

2019-12-07 Thread AudioGames . net Forum — Developers room : Turkce_Rap via Audiogames-reflector


  


Re: Pygame problem

@7You are helpfull thank You.

URL: https://forum.audiogames.net/post/483497/#p483497




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Pygame problem

2019-12-06 Thread AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector


  


Re: Pygame problem

It seems to work, but doesn't give any feedback when your pressing the arrow keys. I've fiddled with it abit so it should be a bit more clear:import pygame, pygame.locals as pl

class menu:
def __init(self):
  self.menu_choices = [] #Our menu options

def add_item(self, item):
  self.menu_choices.append(item)

def reset(self):
  self.menu_choices = []
  #Other reset settings go here

def run(self):
  choice = 0
  while 1: #Continuously check for user input
   for event in pygame.event.get():
 if event.type == pygame.KEYDOWN:
  if event.key == pl.K_UP and choice > 0: #Prevent negative menu options
   choice -= 1
   print(self.menu_choices[choice])
   #To output an option, just do speak(self.menu_choices[choice])
   #No exact speech code is provided because I do not know what you will use for speech.
   #The same is true for sound
  if event.key == pl.K_DOWN and choice < len(self.menu_choices)-1: #Prevent negative menu options
   choice += 1
   print(self.menu_choices[choice])
   #To output an option, just do speak(self.menu_choices[choice])
   #No exact speech code is provided because I do not know what you will use for speech.
   #The same is true for sound
  if event.key == pl.K_RETURN: #User pressed enter
   return choice #We can see what the user chose

pygame.init()
pygame.display.set_mode((600, 400))
pygame.display.set_caption("example menu")
m = menu()

def main():
m.reset() #Make sure nothing is left in our menu
m.add_item("start game")
m.add_item("quit")
choice = m.run()
print(m.menu_choices[choice]+' selected')
pygame.quit()

main()

URL: https://forum.audiogames.net/post/483462/#p483462




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Pygame or PyQt which Gui?

2019-12-06 Thread AudioGames . net Forum — Developers room : keithwipf1 via Audiogames-reflector


  


Re: Pygame or PyQt which Gui?

I think there is a way that you can take WX and run the Event loop whenever you want, without breaking your game loop.I did some simple code that did this.I think it had to do with wx.event or something and the Main loop.

URL: https://forum.audiogames.net/post/48/#p48




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Pygame problem

2019-12-06 Thread AudioGames . net Forum — Developers room : Turkce_Rap via Audiogames-reflector


  


Re: Pygame problem

Guys i've solved shuttingdown problem but i can't navigate the example menues by pressing errow keys.@6it's amerikranian's code below:#part1import pygame, menupygame.init()pygame.display.set_mode((600, 400))pygame.display.set_caption("example menu")m = menu.menu()def main(): m.reset() #Make sure nothing is left in our menu  m.add_item("start game") m.add_item("quit") choice = m.run() print(m.menu_choices[choice])main()#part2import pygame, pygame.locals as plclass menu: def __init(self):  self.menu_choices = [] #Our menu options def add_item(self, item):  self.menu_choices.append(item) def reset(self):  self.menu_choices = []  #Other reset settings go here def run(self):  choice = 0  while 1: #Continuously check for user input   for event in pygame.event.get():     if event.type == pygame.KEYDOWN:      if event.key == pl.K_UP and choice > 0: #Prevent negative menu options       choice -= 1       #To output an option, just do speak(self.menu_choices[choice])       #No exact speech code is provided because I do not know what you will use for speech.       #The same is true for sound      if event.key == pl.K_DOWN and choice < len(self.menu_choices)-1: #Prevent negative menu options       choice += 1       #To output an option, just do speak(self.menu_choices[choice])       #No exact speech code is provided because I do not know what you will use for speech.       #The same is true for sound      if event.key == pl.K_RETURN: #User pressed enter       return choice #We can see what the user chose

URL: https://forum.audiogames.net/post/483249/#p483249




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Pygame or PyQt which Gui?

2019-12-06 Thread AudioGames . net Forum — Developers room : Turkce_Rap via Audiogames-reflector


  


Re: Pygame or PyQt which Gui?

This topic has inlightent me a lot. Let's go on  none gaming projects.

URL: https://forum.audiogames.net/post/483247/#p483247




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Pygame or PyQt which Gui?

2019-12-06 Thread AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector


  


Re: Pygame or PyQt which Gui?

Pygame, Pyglet, wxPython, PyQt, etc. They all have uses outside gaming, it just depends on what you plan on doing. Libraries like PyQt and wxPython though tend to be optimized more towards sharing resources with the system, and for losing context to other programs, whereas Pyglet and Pygame tend to take more control and share less for higher performance or for running continuous simulations. As an example though, for BrushTone I used Pyglet, though in other projects i've used wxPython for a menu widget system and combined it with an OpenGL context from Pyglet into the backend for better image data handling, such as with AudiMesh3D. Neither of those projects required dedicated control for a continuous simulation or high performance, so it didn't really matter if they lost focus.

URL: https://forum.audiogames.net/post/483093/#p483093




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Pygame or PyQt which Gui?

2019-12-06 Thread AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector


  


Re: Pygame or PyQt which Gui?

@3, this is incorrect. WXPython and QT are both accessible; it is the custom elements and widgets that are not. I would however not recommend you use a non-game-specific GUI in your game without a very good reason and before the game loop takes control of the program. After you have handed control to the game loop, you should not use any more non-game-specific GUI functionality (i.e. use SFGUI for SFML over QT). Doing this is not only a bad idea but most likely won't work. This is because non-game-specific GUIs (called standard GUIs, instead of immediate-mode ones) are designed to run on the applications main thread and control the application entirely or nearly so. Using a non-immediate-mode GUI in your main thread will cause extreme harm to your games performance because the game loop will be unable to execute anything. In the game, the entire universe will halt waiting for that GUI loop to terminate, which may never happen; and if or when it does, everything that was queued up during that blocking cycle will execute simultaneously. The execution of the GUI loop also has a very high chance of destabilizing your game loop -- which is never good.To put this into perspective, when your game loop is running, physics, graphics, sound position and 3D calculations, etc., are being executed all in a strict, serialized order. This execution  may happen hundreds of times a second -- this is the frames per second, or FPS, because each execution of that game loop is a frame. If you then run a standard GUI loop in the middle of that game loops execution, the FPS drops to zero and the universe is dead until that loop terminates.Typically, the game loop uses some formula to calculate precisely how long it should wait for the next frame. During this time window, the loop sleeps. As an example, typically I set my FPS to (say) 60, then calculate the number of milliseconds to sleep by dividing 1000 by the number of frames, i.e.:import time
fps = 60
sleep_ticks = int(1000 / fps)
next_game_tick = int(time.time())
sleep_time = 0Then, in my game loop:next_game_tick += skip_ticks
sleep_time = next_game_tick -int( time.time())
if sleep_time>=0:
  time.sleep(sleep_time / 1000)
# game loop goes hereNote that the usage of the time package is discouraged and you should use a far more accurate time measurement system like Pygames clock system. The usage of the time package was purely illustrative.Note that this game loop is only one way of making a game loop. There are various ways of makign one, but this one is constant and there is less difficulty with it, so it is easier to get started with. I strongly encourage you to explore other avenues for game loop code; perhaps you may find a way for game loops and GUI loops to coexist.

URL: https://forum.audiogames.net/post/483089/#p483089




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Pygame or PyQt which Gui?

2019-12-06 Thread AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector


  


Re: Pygame or PyQt which Gui?

@3, this is incorrect. WXPython and QT are both accessible; it is the custom elements and widgets that are not. I would however not recommend you use a non-game-specific GUI in your game without a very good reason and before the game loop takes control of the program. After you have handed control to the game loop, you should not use any more non-game-specific GUI functionality (i.e. SFGUI for SFML). Doing this is not only a bad idea but most likely won't work. This is because non-game-specific GUIs (called standard GUIs, instead of immediate-mode ones) are designed to run on the applications main thread and control the application entirely or nearly so. Using a non-immediate-mode GUI in your main thread will cause extreme harm to your games performance because the game loop will be unable to execute anything. In the game, the entire universe will halt waiting for that GUI loop to terminate, which may never happen; and if or when it does, everything that was queued up during that blocking cycle will execute simultaneously. The execution of the GUI loop also has a very high chance of destabilizing your game loop -- which is never good.To put this into perspective, when your game loop is running, physics, graphics, sound position and 3D calculations, etc., are being executed all in a strict, serialized order. This execution  may happen hundreds of times a second -- this is the frames per second, or FPS, because each execution of that game loop is a frame. If you then run a standard GUI loop in the middle of that game loops execution, the FPS drops to zero and the universe is dead until that loop terminates.Typically, the game loop uses some formula to calculate precisely how long it should wait for the next frame. During this time window, the loop sleeps. As an example, typically I set my FPS to (say) 60, then calculate the number of milliseconds to sleep by dividing 1000 by the number of frames, i.e.:import time
fps = 60
sleep_ticks = int(1000 / fps)
next_game_tick = int(time.time())
sleep_time = 0Then, in my game loop:next_game_tick += skip_ticks
sleep_time = next_game_tick -int( time.time())
if sleep_time>=0:
  time.sleep(sleep_time / 1000)
# game loop goes hereNote that the usage of the time package is discouraged and you should use a far more accurate time measurement system like Pygames clock system. The usage of the time package was purely illustrative.Note that this game loop is only one way of making a game loop. There are various ways of makign one, but this one is constant and there is less difficulty with it, so it is easier to get started with. I strongly encourage you to explore other avenues for game loop code; perhaps you may find a way for game loops and GUI loops to coexist.

URL: https://forum.audiogames.net/post/483089/#p483089




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Pygame problem

2019-12-05 Thread AudioGames . net Forum — Developers room : ashleygrobler04 via Audiogames-reflector


  


Re: Pygame problem

and do you mind posting us the strings that you have in the menu? just so that we can see if there is not some or other \ or ' or " that should not belong there.

URL: https://forum.audiogames.net/post/483087/#p483087




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Pygame or PyQt which Gui?

2019-12-05 Thread AudioGames . net Forum — Developers room : NicklasMCHD via Audiogames-reflector


  


Re: Pygame or PyQt which Gui?

wx python. Pygame was not designed for non-game applications and qt is just inaccessible.

URL: https://forum.audiogames.net/post/483070/#p483070




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Pygame problem

2019-12-05 Thread AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector


  


Re: Pygame problem

Hi. How exactly does it shut down? Does it give you an error? Any output on the screen before closing?

URL: https://forum.audiogames.net/post/483030/#p483030




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Pygame problem

2019-12-05 Thread AudioGames . net Forum — Developers room : Hijacker via Audiogames-reflector


  


Re: Pygame problem

We'll need your code to sort things out, everything else simply doesn't work.

URL: https://forum.audiogames.net/post/482970/#p482970




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Pygame or PyQt which Gui?

2019-12-05 Thread AudioGames . net Forum — Developers room : Hijacker via Audiogames-reflector


  


Re: Pygame or PyQt which Gui?

Usually WX Python if needed, Qt should be fine though.

URL: https://forum.audiogames.net/post/482969/#p482969




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Pygame problem

2019-12-05 Thread AudioGames . net Forum — Developers room : Turkce_Rap via Audiogames-reflector


  


Re: Pygame problem

Tried with an other example code and got this same message: "Hello from the pygame community. https://www.pygame.org/contribute.html"

URL: https://forum.audiogames.net/post/482952/#p482952




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Pygame problem

2019-12-05 Thread AudioGames . net Forum — Developers room : Turkce_Rap via Audiogames-reflector


  


Pygame problem

Sometimes Python is killing me and i live one of these moments.i m trying to run a pygame menu, it only gives me the Pygame's hello message, then shuts down.it's the exact code that is posted with this artical on audiogames: https://forum.audiogames.net/topic/3014 … -and-more/i only replaced English class/func names/class names by Turkish alternatives, didn't touch the wrest.1.i ran it on command promt.2.i use nvda as screen reader.3.two files in same foulder.5.i've also tried on Windows environment, i got the same result.

URL: https://forum.audiogames.net/post/482948/#p482948




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Pygame or PyQt which Gui?

2019-12-05 Thread AudioGames . net Forum — Developers room : Turkce_Rap via Audiogames-reflector


  


Pygame or PyQt which Gui?

What gui do You use for Your none gaming programing projects?

URL: https://forum.audiogames.net/post/482909/#p482909




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: keyboard input in pygame extremely unreliable

2019-12-02 Thread AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector


  


Re: keyboard input in pygame extremely unreliable

As others pointed out, how your processing the keyboard events is sub-optimal. Typically you should be tapping the event buffer only once per cycle, and either do all your checks then, or collect the results to pass off to other functions or classes. Generally, I tend to process key input into a list to pass off to other functions or classes as necessary, though there are other ways of structuring it. I've tweaked your code abit and changed it so it dumps the key event buffer into such a list, then do checks to see if desired keys are in it, and process it from there. I think you'll find it much more responsive:import pygame, pygame.locals as pl, pygame.time as time
import sys

def keyp():
 keys = []
 for event in pygame.event.get():
  if event.type == pygame.KEYDOWN:
   keys.append(event.key)
 return keys

def main():
pygame.init()
screen = pygame.display.set_mode((600, 400))
pygame.display.set_caption("play with pan")

x = 0
while True:
  keys = keyp()
  if pl.K_LEFT in keys:
   x-=1
   print(x)
  if pl.K_RIGHT in keys:
   x+=1
   print(x)
  if pl.K_ESCAPE in keys:
   pygame.quit()
   sys.exit()

main()

URL: https://forum.audiogames.net/post/482003/#p482003




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: keyboard input in pygame extremely unreliable

2019-12-02 Thread AudioGames . net Forum — Developers room : NicklasMCHD via Audiogames-reflector


  


Re: keyboard input in pygame extremely unreliable

Hi @simterLucia's documentation can be found here.

URL: https://forum.audiogames.net/post/481995/#p481995




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: keyboard input in pygame extremely unreliable

2019-12-02 Thread AudioGames . net Forum — Developers room : Perry Simm via Audiogames-reflector


  


Re: keyboard input in pygame extremely unreliable

Hi!I agree with Rastislav over why keys are dropped. You nailed it.Don't search the entire event history for one key, discarding other keys as you go. Instead, define a key event handler that deals with them all and dispatches them to where they are handled.Cheers Perry

URL: https://forum.audiogames.net/post/481989/#p481989




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: keyboard input in pygame extremely unreliable

2019-11-30 Thread AudioGames . net Forum — Developers room : ashleygrobler04 via Audiogames-reflector


  


Re: keyboard input in pygame extremely unreliable

but they are pritty self explanitory

URL: https://forum.audiogames.net/post/481672/#p481672




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: keyboard input in pygame extremely unreliable

2019-11-30 Thread AudioGames . net Forum — Developers room : simter via Audiogames-reflector


  


Re: keyboard input in pygame extremely unreliable

@11 i see that, but a lot of functions are not described, and just their names are standing there.

URL: https://forum.audiogames.net/post/481581/#p481581




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: keyboard input in pygame extremely unreliable

2019-11-30 Thread AudioGames . net Forum — Developers room : ashleygrobler04 via Audiogames-reflector


  


Re: keyboard input in pygame extremely unreliable

Hi there, pygame does have directect keyboard and window support...

URL: https://forum.audiogames.net/post/481547/#p481547




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: keyboard input in pygame extremely unreliable

2019-11-30 Thread AudioGames . net Forum — Developers room : Rastislav Kiss via Audiogames-reflector


  


Re: keyboard input in pygame extremely unreliable

Hmm, I see. Then just ignore my note on the timing, that should be okay, but what I said about key presses still remains.I'm wondering, doesn't pygame has a built-in method to check for a key state directly? Gaming libraries usually have such functionality, infact that was the way I was doing it all the time with DirectX or basic system libraries before I first learned about more advanced uses of events and developed much better solutions for capturing shortcuts.I would be surprised, if pygame didn't have such function. It could be exactly what you want.Best regardsRastislav

URL: https://forum.audiogames.net/post/481539/#p481539




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: keyboard input in pygame extremely unreliable

2019-11-30 Thread AudioGames . net Forum — Developers room : ashleygrobler04 via Audiogames-reflector


  


Re: keyboard input in pygame extremely unreliable

it's not that hard, just ask around here if there are things that you can't understand. and by the way, if you look on the github, you can find the latest documentation. you can also generate your own documentation acoarding to instructions.

URL: https://forum.audiogames.net/post/481535/#p481535




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: keyboard input in pygame extremely unreliable

2019-11-30 Thread AudioGames . net Forum — Developers room : simter via Audiogames-reflector


  


Re: keyboard input in pygame extremely unreliable

@9 yeah, but i can't find propper documentation for it.

URL: https://forum.audiogames.net/post/481523/#p481523




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: keyboard input in pygame extremely unreliable

2019-11-30 Thread AudioGames . net Forum — Developers room : ashleygrobler04 via Audiogames-reflector


  


Re: keyboard input in pygame extremely unreliable

Or if you reelly want to make life for your self more simple, use lucia. it's great!

URL: https://forum.audiogames.net/post/481513/#p481513




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: keyboard input in pygame extremely unreliable

2019-11-30 Thread AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector


  


Re: keyboard input in pygame extremely unreliable

The function empties the event ... queue? Stack? So checking for a single event means that you miss all the other events. If you really want it to work like BGT, you need a dict to map keys to bools, and have a function that updates those for every iteration of your loop.Handling that with Python's scope rules seems kinda annoying, but probably easier than making a whole class for this. If your dict is called keys, you'd put "global keys" as the first line of your function. If it's a class method/property, disregard that.

URL: https://forum.audiogames.net/post/481507/#p481507




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: keyboard input in pygame extremely unreliable

2019-11-30 Thread AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector


  


Re: keyboard input in pygame extremely unreliable

I, C. Unfortunately, your modifications would not work for reasons outlined above.  Still, E for effort.

URL: https://forum.audiogames.net/post/481493/#p481493




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: keyboard input in pygame extremely unreliable

2019-11-30 Thread AudioGames . net Forum — Developers room : simter via Audiogames-reflector


  


Re: keyboard input in pygame extremely unreliable

@5 I modified your key pressing example from tutorial 2 so it works more like in bgt.@3 and 4, i am using the pygame.time, not the python time. This module indead waits secs, not ms. But thanks for the suggestion, it was just working like that in bgt so i thought it may work in py as well.

URL: https://forum.audiogames.net/post/481489/#p481489




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: keyboard input in pygame extremely unreliable

2019-11-30 Thread AudioGames . net Forum — Developers room : simter via Audiogames-reflector


  


Re: keyboard input in pygame extremely unreliable

@5 Didn't i say that i modified this slightly?@3 and 4, i am using the pygame.time, not the python time. This module indead waits secs, not ms. But thanks for the suggestion, it was just working like that in bgt so i thought it may work in py as well.

URL: https://forum.audiogames.net/post/481489/#p481489




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: keyboard input in pygame extremely unreliable

2019-11-30 Thread AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector


  


Re: keyboard input in pygame extremely unreliable

@1, could you please point out where in my guide did I show such a method? For the life of me, I can't find it.Your code also looks like it has several mistakes besides the wrong keyp function. I would recommend comparing it with my examples in the guide to see what is different and then proceeding from there.

URL: https://forum.audiogames.net/post/481466/#p481466




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: keyboard input in pygame extremely unreliable

2019-11-30 Thread AudioGames . net Forum — Developers room : Rastislav Kiss via Audiogames-reflector


  


Re: keyboard input in pygame extremely unreliable

Oh yeah, sorry for doubleposting, but this is important.I have just actually read, what you wrote, and I guess you are handling events in a wrong way.Imagine them like e-mails coming to your inbox, notifying you about some changes, like key presses. When you check newly arrived e-mail, you read its content and then throw it away.Now, what you actually wrote is, that with the keyp method, you are checking new e-mails, until you find one about a key press, and if that key press is of key, which you want to see, then you return true.But what if it's another key?Then you just throw it away, so the other callings of the keyp function have no idea, that their key was pressed.Because of this, chance of whether the key pressed by you will be recognized is related to which calling of keyp function will you hit in time. If the correctone, key will be classified, otherwise it will be just ignored.Best regardsRastislav

URL: https://forum.audiogames.net/post/481455/#p481455




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: keyboard input in pygame extremely unreliable

2019-11-30 Thread AudioGames . net Forum — Developers room : Rastislav Kiss via Audiogames-reflector


  


Re: keyboard input in pygame extremely unreliable

Hi,5 is too too much. time.sleep is taking its first parameter in seconds, not milliseconds, like bgt's wait.So time.sleep(0.005) is what you most likely want to do, or some other value around that, 0.01 should work fine as well.Including no sleep will cause overuse of cpu, what could result in slower reactions.Try to include the sleep interval I mentioned. I didn't use pygame, but I think it could work just fine.And yeah, that indentation mistake regarding methods is true, everything under def should be indented, although I'm wondering if this isn't just a copy error, as Python should warn you about wrong indentation.Best regardsRastislav

URL: https://forum.audiogames.net/post/481451/#p481451




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: keyboard input in pygame extremely unreliable

2019-11-30 Thread AudioGames . net Forum — Developers room : Ty via Audiogames-reflector


  


Re: keyboard input in pygame extremely unreliable

You didn't indent the first line in your functions

URL: https://forum.audiogames.net/post/481443/#p481443




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


keyboard input in pygame extremely unreliable

2019-11-30 Thread AudioGames . net Forum — Developers room : simter via Audiogames-reflector


  


keyboard input in pygame extremely unreliable

Hi. Sorry for another question after so short time. But how ever, I tried to build a small aplication tha allowes you to test pythons pan by using the arrow keys and escape to exit. Here's my key pressed funktion, it's from americranians py tutorial with a small modification.def keyp(key): for event in pygame.event.get():  if event.type == pygame.KEYDOWN: #A key event that has been detected   if event.key == key:    return TrueHow ever, if you add more then 1 key to the while loop the input starts geting really unreliable, keeps dropping keys, and you have to press every key a thun of times so it gets accepted. It's geting even worse if you include a wait statement. Here's my code. I used carters sound ans soundpositioning class.import pygame, pygame.locals as pl, pygame.time as timeimport sysimport sound, sound_positioning as spdef keyp(key): for event in pygame.event.get():  if event.type == pygame.KEYDOWN:    if event.key == key:    return Truedef main(): pygame.init() screen = pygame.display.set_mode((600, 400))  pygame.display.set_caption("play with pan")s=sound.sound() s.load("sound.mp3") x=0 s.play_looped() while True:  time.wait(5)  sp.position_sound_1d(s,0,x,2,2)  if keyp(pl.K_LEFT)==True:   x-=1  if keyp(pl.K_RIGHT):   x+=1  if keyp(pl.K_ESCAPE):   sys.exit()main()right now the keys are almost not responding at all cause the wait statement is in there. Can anyone please tell me what i am doing wrong? Greatings and thanks, simter.

URL: https://forum.audiogames.net/post/481441/#p481441




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Pygame and graphics?

2019-09-12 Thread AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector


  


Re: Pygame and graphics?

Its a bit on the rough side as you have to tap the arrow keys to move instead of hold them but principles there. This will start you on the left side of the image, there are collision checks so you won't leave the images bounds.import pygame
from pygame import mixer
import sys

def Example():
#initialize pygame
pygame.init()
#initialize sound mixer
mixer.init()
#create display
window = pygame.display.set_mode([640,480])
#32 by 32 image
player = pygame.image.load('sample.png')
#1280 by 960 image
background = ""

offset = [0,-480]

#main update loop
while True:
#add gravity setting to have the player "fall" after jumping
if offset[1] > -480:
offset[1] -= 1
#handle key input
for event in pygame.event.get():
if event.type == pygame.KEYDOWN:
#if space is pressed, jump
if event.key == pygame.K_SPACE:
#keep within bounds of top of image
if offset[1] < 0:
offset[1] += 10
#move left
if event.key == pygame.K_LEFT:
#keep from moving beyond left bounds of image
if offset[0] < 0:
offset[0] += 10
#move right
if event.key == pygame.K_RIGHT:
#keep from moving beyond right bounds of image
if offset[0] > -640:
offset[0] -= 10
#if escape is pressed, quit
if event.key == pygame.K_ESCAPE:
pygame.quit()
sys.exit(0)

#clear window for next render
window.fill((0,0,0))
#draw background
window.blit(background,(offset[0],offset[1]))
#draw player
window.blit(player,(320-(player.get_width()/2),360))
#update window
pygame.display.update()

Example()

URL: https://forum.audiogames.net/post/461578/#p461578




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Pygame and graphics?

2019-09-12 Thread AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector


  


Re: Pygame and graphics?

Oops, yeah you should probably swap offset[0] for x and offset[1] for y. There have been many times i've dealt with 2D arrays in rendering where Y represents index[0] for the row, and X represents index[1] for the values in the list, in any case its not really relevant here.In the case of Pygame, 0 by 0 would be the upper left corner of the screen, so from there objects can be placed around the screen like so:X by Y: Object does not move-X by Y: Object moves left-X by -Y: Object moves to the upper leftX by -Y: Object moves up+X by -Y: Object moves upper right+X by Y: Object moves right+X by +Y: Object moves to the lower rightX by +Y: Object moves down-X by +Y: Object moves lower leftSo, lets say you have a screen resolution of 640 by 480. Now lets say you have a sprite thats 32 by 32, with an offset of 0 by 0, this would put the upper left of the sprite in the upper left of the screen. If its position was 320 by 320, it would be near the middle of the window, but not exactly, you'd need to adjust for the size of the sprite itself, so 320-(sprite.width/2) by 320-(sprite.height/2) would center it in the middle of the screen. In the case of the sprite being at -320 by -320, it would be completely off the screen and invisible as anything less than 0 aren't drawn to the screen, so -320+sprite.width = -288 by -320+sprite.height = -288, both are negative values, so the sprite isn't drawn.In the case of the background, you could take a background image thats 1280 by 960 with an offset of 0 by -480, which would put the left side of the image to the left edge of the window, and the bottom of the image to the bottom of the screen. By moving the player character right you'd subtract the X offset, which would move the background image left giving the illusion of the player moving to the right, or by jumping you could add to the Y offset moving the image down, giving the illusion the player is jumping up.As mentioned, I can provide a working example demonstrating this.

URL: https://forum.audiogames.net/post/461552/#p461552




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Pygame and graphics?

2019-09-12 Thread AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector


  


Re: Pygame and graphics?

Yeah, I think I would need to see that to truly understand.

URL: https://forum.audiogames.net/post/461565/#p461565




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Pygame and graphics?

2019-09-12 Thread AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector


  


Re: Pygame and graphics?

Oops, yeah you should probably swap offset[0] for x and offset[1] for y. There have been many times i've dealt with 2D arrays in rendering where Y represents index[0] for the row, and X represents index[1] for the values in the list, in any case its not really relevant here.In the case of Pygame, 0 by 0 would be the upper left corner of the screen, so from there objects can be placed around the screen like so:X by Y: Object does not move-X by Y: Object moves left-X by -Y: Object moves to the upper leftX by -Y: Object moves up+X by -Y: Object moves upper right+X by Y: Object moves right+X by +Y: Object moves to the lower rightX by +Y: Object moves down-X by +Y: Object moves lower leftSo, lets say you have a screen resolution of 640 by 480. Now lets say you have a sprite thats 32 by 32, with an offset of 0 by 0, this would put the upper left of the sprite in the upper left of the screen. If its position was 320 by 320, it would be near the middle of the window, but not exactly, you'd need to adjust for the size of the sprite itself, so 320-(sprite.width/2) by 320-(sprite.height/2) would center it in the middle of the screen. In the case of the sprite being at -320 by -320, it would be completely off the screen and invisible as anything less than 0 aren't drawn to the screen, so -320+sprite.width = -288 by -320+sprite.height = -288, both are negative values, so the sprite isn't drawn.In the case of the background, you could take a background image thats 1280 by 960 with an offset of 0 by 480, which would put the left side of the image to the left edge of the window, and the bottom of the image to the bottom of the screen. By moving the player character right you'd subtract the X offset, which would move the background image left giving the illusion of the player moving to the right, or by jumping you could add to the Y offset moving the image down, giving the illusion the player is jumping up.As mentioned, I can provide a working example demonstrating this.

URL: https://forum.audiogames.net/post/461552/#p461552




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Pygame and graphics?

2019-09-12 Thread AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector


  


Re: Pygame and graphics?

Oops, yeah you should probably swap offset[0] for x and offset[1] for y. There have been many times i've dealt with 2D arrays in rendering where Y represents index[0] for the row, and X represents index[1] for the values in the list, in any case its not really relevant here.In the case of Pygame, 0 by 0 would be the upper left corner of the screen, so from there objects can be placed around the screen like so:X by Y: Object does not move-X by Y: Object moves left-X by -Y: Object moves to the upper leftX by -Y: Object moves up+X by -Y: Object moves upper right+X by Y: Object moves right+X by +Y: Object moves to the lower rightX by +Y: Object moves down-X by +Y: Object moves lower leftSo, lets say you have a screen resolution of 640 by 480. Now lets say you have a sprite thats 32 by 32, with an offset of 0 by 0, this would put the upper left of the sprite in the upper left of the screen. If its position was 320 by 320, it would be near the middle of the window, but not eactly, but you'd need to asdjust for the size of the sprite itself, so 320-(sprite.width/2) by 320-(sprite.height/2) would center it in the middle of the screen. In the case of the sprite being at -320 by -320, it would be completely off the screen and invisible as anything less than 0 aren't drawn to the screen, so -320+sprite.width = -288 by -320+sprite.height = -288, both are negative values, so the sprite isn't drawn.In the case of the background, you could take a background image thats 1280 by 960 with an offset of 0 by 480, which would put the left side of the image to the left edge of the window, and the bottom of the image to the bottom of the screen. By moving the player character right you'd subtract the X offset, which would move the background image left giving the illusion of the player moving to the right, or by jumping you could add to the Y offset moving the image down, giving the illusion the player is jumping up.As mentioned, I can provide a working example demonstrating this.

URL: https://forum.audiogames.net/post/461552/#p461552




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Pygame and graphics?

2019-09-12 Thread AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector


  


Re: Pygame and graphics?

@8:In your example, I see this:window.blit(background,(0-offset[1],0-offset[0]))Isn't the first number in the offset x and the second y? Am I missing something here? Why are you subtracting the last number of the offset first?You also mention the offset increasing and decreasing. I am assuming that the offset would do so as the player moves. What would happen if the offset was at, say, 320, 320? How bout -320, -320?

URL: https://forum.audiogames.net/post/461462/#p461462




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Pygame and graphics?

2019-09-11 Thread AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector


  


Re: Pygame and graphics?

I always like to keep it possible to resize the window (scaling images with pygame is probably cumbersome to keep fast, but I haven't checked in a long time, so maybe not?), which complicates things further. Between the unreliability of guessing the user's screen size/settings, accessibility, and how small typical examples and tutorials make the window (400×300 hardly feels like it should be usable for anything more visually complex than Snake, but I might possibly have a bias in that regard ), it just seems like good practice. Same with font sizes. And when things get that complex, having a class (or at least a module) for managing it helps a lot.

URL: https://forum.audiogames.net/post/461126/#p461126




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Pygame and graphics?

2019-09-10 Thread AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector


  


Re: Pygame and graphics?

Blit is still the correct approach, just used in a different way. As CAE_Jones mentioned, you'd use a camera offset to position everything around the player, as opposed to the player itself to create the illusion that the player is moving around the map, whilst they stay fixed in a single position.So, lets say your working with a window thats 640 by 480, you'd want to position the player in the center, so 320 by 240, minus the image size of the player divided by 2. Then you could position either a large background image as your environment, or a series of smaller tiles, and move them based on the camera offset. So something like:window = pygame.display.set_mode([640,480])
offset = [0,0]

...

window.blit(background,(0-offset[1],0-offset[0]))
window.blit(player,(320-(player.width/2), 240-(player.height/2)))Whenever you press a key to move around, you'd add or subtract the offset, not the players position, thus moving the environment around you. Some side scrollers have some give to this though, where the player character can move within a  certain range within the center of the screen before hitting a collision box, where it then starts moving the camera offset instead, thus keeping the player on the screen. If you like, I can provide an example of this.

URL: https://forum.audiogames.net/post/460999/#p460999




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Pygame and graphics?

2019-09-10 Thread AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector


  


Re: Pygame and graphics?

Blit is still the correct approach, just used in a different way. As CE_Jones mentioned, you'd use a camera offset to position everything around the player, as opposed to the player itself to create the illusion that the player is moving around the map, whilst they stay fixed in a single position.So, lets say your working with a window thats 640 by 480, you'd want to position the player in the center, so 320 by 240, minus the image size of the player divided by 2. Then you could position either a large background image as your environment, or a series of smaller tiles, and move them based on the camera offset. So something like:window = pygame.display.set_mode([640,480])
offset = [0,0]

...

window.blit(background,(0-offset[1],0-offset[0]))
window.blit(player,(320-(player.width/2), 240-(player.height/2)))Whenever you press a key to move around, you'd add or subtract the offset, not the players position, thus moving the environment around you. Some side scrollers have some give to this though, where the player character can move within a  certain range within the center of the screen before hitting a collision box, where it then starts moving the camera offset instead, thus keeping the player on the screen. If you like, I can provide an example of this.

URL: https://forum.audiogames.net/post/460999/#p460999




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Pygame and graphics?

2019-09-10 Thread AudioGames . net Forum — Developers room : ashleygrobler04 via Audiogames-reflector


  


Re: Pygame and graphics?

Oh, yeah i see what you meen. then the immage will be on the other side of the screen, and at the end of the day it would not be visable on the screen any more if i am correct. so do you only want to move the view of the character around on the screen?

URL: https://forum.audiogames.net/post/460933/#p460933




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Pygame and graphics?

2019-09-10 Thread AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector


  


Re: Pygame and graphics?

Blit only accepts x and y, and I want the character to stay still as we move across the screen, so if I'd blit the character's current position to the screen it would appear that the character is moving across the screen, which is not what I want.

URL: https://forum.audiogames.net/post/460906/#p460906




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Pygame and graphics?

2019-09-10 Thread AudioGames . net Forum — Developers room : ashleygrobler04 via Audiogames-reflector


  


Re: Pygame and graphics?

why don't you use the blit functions to move an immage to the required position?

URL: https://forum.audiogames.net/post/460806/#p460806




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Pygame and graphics?

2019-09-09 Thread AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector


  


Re: Pygame and graphics?

The coordinates that go to the draw functions should not be (obj.x, obj.y), but rather, (obj.x-camera.x, obj.y-camera.y). Leaving this out is equivalent to leaving the camera at (0, 0).A class for managing this sort of thing could handle this, so you don't have to type every single draw command that way, when you could just wrap the draw functions once. Ex:class Graphics2D :
camera_x, camera_y, scale_x, scale_y = (0, 0, 1.0, 1.0)
backcolor, forecolor = ((0, 0, 0), (255, 255, 255))
drawsurface = None
def __init__ (self, surf) :
self.drawsurface = surf

def reset (self) :
self.camera_x = 0
self.camera_y = 0
 self.scale_x = 1.0
self.scale_y = 1.0

def translate (self, x, y) :
"""Position the camera"""
self.camera_x = x
self.camera_y = y

def scale (self, x, y) :
self.scale_x = x
 self.scale_y = y

def set_color (self, newcolor) :
"""sets the color for all subsequent draw commands """
self.forecolor = newcolor # todo: make sure this is a 3tuple

def fill_rect (self, x, y, width, height) :
# (I don't remember off the top of my head if pygame.draw.rect takes numbers, or rect objects. I'll assume it's (x, y, w, h, color) for now.
   x = (x * self.scale_x) - self.camera_x
y = (y * self.scale_y) - self.camera_y
#todo: negative scale values probably need special handling. You'll probably wind up wanting to flip something at some point.
pygame.draw.rect (self.surf, x, y, width * self.scale_x, height * self.scale_y, self.forecolor)Etc. I'm pretty sure there are typos in there. It's meant to show the idea.

URL: https://forum.audiogames.net/post/460762/#p460762




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Pygame and graphics?

2019-09-09 Thread AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector


  


Re: Pygame and graphics?

I am not sure that I understand, can you elaborate?

URL: https://forum.audiogames.net/post/460709/#p460709




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Pygame and graphics?

2019-09-09 Thread AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector


  


Re: Pygame and graphics?

You want to have your drawing take an offset for the camera's position. Java.awt.Graphics handles this natively with the translate and transform methods, a similar class for pygame graphics might be helpful?

URL: https://forum.audiogames.net/post/460703/#p460703




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Pygame and graphics?

2019-09-09 Thread AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector


  


Pygame and graphics?

I've tried looking this up, I really did, but for the life of me... I can't find the answer!Suppose that we have a side scroller game. Nothing too complex, mind you, just walking along and shooting things. The key is "walking along". Our perspective never changes. We are not looking at the screen as if we were a third person, we have our character's point of view. With audio, this is simple to implement (just play footsteps in the center), but what about graphics? I looked at the pygame drawing functions and couldn't really find my answer. I also have tried searching, but everything I've found is the character gliding across the screen, which is again, not what I want. Suggestions andor tips as to how to accomplish this would be appreciated.

URL: https://forum.audiogames.net/post/460685/#p460685




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Issue with pygame

2019-08-15 Thread AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector


  


Re: Issue with pygame

Pygame works much, much better with event-based input, rather than polling. If you really want to use polling, you'd be better off keeping your own list of pressed/released keys and updating them every frame.A single list could handle that, if you use ints with different values for pressed / down / up / released. I'd go with 1 bit for down/up, and one for the state in the previous frame, but whatever works.

URL: https://forum.audiogames.net/post/455636/#p455636




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Issue with pygame

2019-08-15 Thread AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector


  


Issue with pygame

I'm trying to create a rapper for pygame's keyboard to make life easier when I do key logic. Here's my code:import pygame, pygame.locals as pl
pygame.init()
pygame.display.set_mode((600, 600))
pygame.display.set_caption("Testing stuff.")
x = 0
y = 0
def main():
 while 1:
  keyloop()
  pygame.time.wait(2)

def keyloop():
 global x
 global y
 if key_pressed(pl.K_UP):
  y += 1
  print(y)
 elif key_pressed(pl.K_RIGHT):
  x += 1
  print(x)

def key_pressed(key):
 for event in pygame.event.get():
  if event.type == pygame.KEYDOWN and event.key == key: return True
 return False

main()The issue here is, when you run this, only the up arrow works. I understand why this happens (I loop through the events and clear them when I check for the up arrow being pressed) but is there any way to fix this problem? It would be really nice if I can just do key_pressed() and key_down() which works beautifully because it's a list.I can't use key_down for pressing keys because it triggers multiple times, and having a timer for each key doesn't seem like the right solution.I also didn't include key_down because it's not used.

URL: https://forum.audiogames.net/post/455630/#p455630




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: User input in pygame?

2019-08-10 Thread AudioGames . net Forum — Developers room : Hijacker via Audiogames-reflector


  


Re: User input in pygame?

I ment entering text as well, and @3 only showed you an example for what I described earlier, thanks for that .Best Regards.Hijacker

URL: https://forum.audiogames.net/post/454480/#p454480




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: User input in pygame?

2019-08-09 Thread AudioGames . net Forum — Developers room : ashleygrobler04 via Audiogames-reflector


  


Re: User input in pygame?

Hi i actually ment input like entering text. but i think @3 gave me an idea on what to use. thanks

URL: https://forum.audiogames.net/post/454431/#p454431




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: User input in pygame?

2019-08-09 Thread AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector


  


Re: User input in pygame?

There's a list of key codes [here], example:import pygame
from pygame import mixer
import sys

def Example():
#initialize pygame
pygame.init()
#initialize sound mixer
mixer.init()
#create display
window = pygame.display.set_mode([640,480])
#load sound
sound = mixer.Sound('tone5.wav')

#main update loop
while True:
for event in pygame.event.get():
if event.type == pygame.KEYDOWN:
#if space is pressed, play sound
if event.key == pygame.K_SPACE:
sound.play()
#if escape is pressed, quit
if event.key == pygame.K_ESCAPE:
pygame.quit()
sys.exit(0)

#update window
pygame.display.update()

Example()If you want to collect and compare text strings, then add a capture for event.unicode like so:for event in pygame.event.get():
if event.type == pygame.KEYDOWN:
text += event.unicode
print(text)

URL: https://forum.audiogames.net/post/454339/#p454339




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: User input in pygame?

2019-08-09 Thread AudioGames . net Forum — Developers room : Hijacker via Audiogames-reflector


  


Re: User input in pygame?

You need to handle keydown events. You know, pygame handles any user interaction by raising events. Those events need to be handled within the main game loop. Whenever a key is used when in the game window (maybe even outside), an event is created. You need to handle those events and take appropriate action.Best Regards.Hijacker

URL: https://forum.audiogames.net/post/454333/#p454333




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


User input in pygame?

2019-08-09 Thread AudioGames . net Forum — Developers room : ashleygrobler04 via Audiogames-reflector


  


User input in pygame?

Hi all, i can't remember if this question has been posted recently, but when i am using pygame for window and keyboard handling, how would i make the user input some text? i don't think the input function is going to work...

URL: https://forum.audiogames.net/post/454322/#p454322




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


  1   2   3   >