Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

100 Neutral

About djtschke

  • Rank
  1. djtschke

    [pygame] sprite - jump method

    Hello everybody, yes, as Ironhorse already said I am working with python and pygame. Thank you for all the input !! I will try to get it working and then let you know again. best regards, djtschke
  2. Hello everybody, I made a sprite object for the player character in a side scrolling jump and run. Now I want to add a method that is called when the space button is pressed and then moves the character sprite up and down again one time. I just have no clue how I do this and would be very glad if someone could give me an impulse into the right direction. best regards, Djtschke
  3. djtschke

    pygame: fit background to resolution

    Ha, solved it myself. has to be: [source lang=python] image = pygame.transform.scale(image, ((im_width * sf_height / im_height), sf_height))
  4. Hello everyone, here is my problem:´ I have coded a scrolling background. The window size of my screen is 200x100 and the size of the background image is 300x100. The scrolling works fine and everything. Now I wanted to code a method that scales the backrgound image proportionally when the window size changes. Somehow the image won't scale. Here is the main code of the scrolling background test: import pygame import engine screen = pygame.display.set_mode((200, 100)) pygame.key.set_repeat(1, 1) running = 1 level_1 = pygame.image.load("bg2.png") level_1 = engine.scale_to_resolution(level_1, screen) background = engine.background(level_1, screen, (0,0)) background.draw() while running: for event in pygame.event.get(): if event.type == pygame.QUIT: running = 0 elif event.type == pygame.KEYDOWN: if event.key == pygame.K_RIGHT: background.scroll_right() if event.key == pygame.K_LEFT: background.scroll_left() pygame.display.flip() and here is the code of the scale_to_resolution() method: def scale_to_resolution(image, surface): im_width, im_height = image.get_size() sf_width, sf_height = surface.get_size() pygame.transform.scale(image, ((im_width * sf_height / im_height), sf_height)) return image thank you for your help !! best regards djtschke
  5. Hello everybody ! Here another newbie question: I coded a while loop to scroll the background of my windows to the left when I press the right arrow key. What I actually want to achieve is that the background scrolls while I am pressing the right arrow key and stops when I release the key. I experimented with if event.type == pygame.KEYUP but I won't get it work. Here is the code for the left scrolling: elif event.type == pygame.KEYDOWN: while event.key == pygame.K_RIGHT: x -= 0.2 y = 0 screen.blit(bg, (x, y)) pygame.display.flip() I hope somebody can help me (to be honest I am sure :) ). best regards, djtschke
  6. I am still using pygame 1.8.1 for I encounter problems when trying to compile version 1.9. So that is the reason, thank you ! I didn't quite understand what you meant as a solution for my scrolling background. I am still pretty new to python and programming generally. Thank you very much !
  7. Hello everybody, here my two questions: -is it possible to rotate a blited image around another point that its center using pygame.transform.rotate ? - I tried to make a scrolling background for a sidescroller using the Surface.scroll function. Python tells my there is no such function ? Why that ? best regards and thank for the help djtschke
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!