I am novice in programming and gamedevelopment. So, I want to create very simple 2D RTS using Python and pygame, and first problem what I collide is camera. I need to create complicated camera under background. It should be able to zoom in / out and move around the keyboard keys. All lessons, that I find, move background or do something unusual without normal explanations.
Can I create this camera in pygame at all? And how? How move camera under background? (I planned to add objects to the background later) How realize zoom?
Now I have a simple code that load background image.
import math, random, sys
from PyQt5.QtWidgets import QDesktopWidget,QApplication
import pygame
app = QApplication(sys.argv)
q = QDesktopWidget().availableGeometry()
pygame.init()
clock = pygame.time.Clock()
FPS = 60
pygame.display.set_caption("New Game")
win = pygame.display.set_mode((q.width(), q.height())) #Creating window like size of screen
bg = pygame.image.load('C:\Py\Game\Image\Kordon3.jpg').convert() #Loading background image
run = True
H = 0
W = 0
while run:
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
keys = pygame.key.get_pressed()
#This keys move background
if keys[pygame.K_LEFT]:
W += 5
elif keys[pygame.K_RIGHT]:
W -= 5
elif keys[pygame.K_DOWN]:
H -= 5
elif keys[pygame.K_UP]:
H += 5
win.blit(bg, (W, H)) #Add/update coordinats of background
pygame.display.update()
clock.tick(FPS)
pygame.quit()