All i wanna do at this point is to test the (soon to be) game and see that the correct sprites are were they are supposed to be.
When i run the game the background is black instead of the green color of my field.png, no other sprites are visible and after a while i get a Runtime error and the game crashes.
Any ideas? -
import pygame, math, sys
-
from pygame.locals import *
-
from livewires import games
-
-
# FPS
-
clock = pygame.time.Clock()
-
FRAMES_PER_SECOND = 30
-
deltat = clock.tick(FRAMES_PER_SECOND)
-
-
class Endzone(pygame.sprite.Sprite):
-
endzone_no_td = pygame.image.load('endzone.png')
-
endzone_td = pygame.image.load('endzone_td.png')
-
-
def __init__(self, position):
-
pygame.sprite.Sprite.__init__(self)
-
self.rect = pygame.Rect(self.endzone_no_td.get_rect())
-
self.rect.center = position
-
-
class Player(pygame.sprite.Sprite):
-
player_image = pygame.image.load('49er.gif')
-
def __init__(self,position,team,pos_in_team):
-
-
if team == 'offense':
-
player_image = pygame.image.load('49er.gif')
-
else:
-
player_image = pygame.image.load('defense.gif')
-
-
""" if pos_in_team... """
-
-
pygame.sprite.Sprite.__init__(self)
-
self.rect = pygame.Rect(self.player_image.get_rect())
-
self.rect.center = position
-
-
def game():
-
my_screen = games.Screen (width=1024, height=768)
-
bg = games.load_image("field.png")
-
my_screen.set_background(bg)
-
def_safety = Player((400,400),'defense','safety')
-
off_tight_end = Player((500,500),'offense','tigth_end')
-
my_screen.mainloop()
-
-
game()
-
4 5004 boxfish 469
Recognized Expert Contributor
Is your background solid green? Livewires may be converting the green pixels to transparent. Try this:
bg = games.load_imag e("field.png" , transparent = False)
If that works, we'll have to work on your sprites next. I don't think loading the player images with pygame is a good idea. If you're going to be using livewires, you might as well let it do that stuff for you. Or you could just use pygame without livewires.
Good luck with the game.
Thanks for the tip, it took care of the runtime error.
I've played around a bit more and now i have another problem.
I get the following error: Traceback (most recent call last):
File "...", line 54, in <module>
game()
File "...", line 47, in game
def_safety = Player('defense ',(40, 40))
File "...", line 36, in __init__
screen.blit(pla yer_image, self.position)
TypeError: invalid destination position for blit
And here is the code: - import pygame, math, sys
-
from pygame.locals import *
-
from livewires import games
-
-
# FPS
-
clock = pygame.time.Clock()
-
FRAMES_PER_SECOND = 30
-
deltat = clock.tick(FRAMES_PER_SECOND)
-
-
screen = pygame.display.set_mode((1024, 768))
-
-
-
class Player(pygame.sprite.Sprite):
-
player_image = pygame.image.load('49er.gif')
-
def __init__(self,team,position):
-
self.team = None
-
self.position = None
-
-
if self.team == 'offense':
-
player_image = pygame.image.load('49er.gif')
-
else:
-
player_image = pygame.image.load('defense.gif')
-
-
screen.blit(player_image, self.position)
-
-
def game():
-
bg = pygame.image.load("field.png")
-
screen.blit(bg, (0,0))
-
-
#DEFENSE
-
def_safety = Player('defense',(40, 40))
-
def_safety.__init__()
-
-
# OFFENSE
-
off_tight_end = Player('offense',(100, 100))
-
def_safety.__init()
-
-
game()
-
I have no idea why the "coordinate s" doesn't work...
boxfish 469
Recognized Expert Contributor
Your init function does nothing with the arguments you pass it, and assigns the members to None. It should be - def __init__(self,team,position):
-
self.team = team
-
self.position = position
I hope this helps.
Ah, that was kinda obvious :)
Thanks alot!
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: VinnieT |
last post by:
I have a load balanced system that consists of 3 production servers. There
are about 20 different applications that are used on these boxes. One of my
applications in particular is used more than the others. Since updating 2
applications, I have had problems on the event log of the servers, following
stopping of the aspnet_ws.exe process.
Something is causing the following error in the windows application event log:
The description for...
|
by: Mike P |
last post by:
I will be passing my function a two dimensional array of varying length.
Within that array is one data point, and the number of times it should loop
through.
So, for example, I might pass this to the function:
example = new Array("A",2);
example = new Array("Q",4);
function loopIt(example);
|
by: bill_hounslow |
last post by:
I'm trying to transfer data from one Sql Server into a table on
another, using a simple INSERT query in an Access database with links
to tables on both servers (the reasons for this are complicated but it
IS the simplest solution, believe me).
The 'Select' clause of the query works fine when run alone, but, when I
run the INSERT query I get a Runtime Error 3167 Record Deleted.
I get the error even when I'm the only person accessing...
|
by: Oberon |
last post by:
How do I deal with this? I am getting an error for each get in the
Game class (see code below).
In the simplified example below I have reduced this to just 3 fields,
one which can be NULL. I have added 3 records to the table and ran the
program but it fails with the error above.
The application is supposed to create the hashtable of records as a
static feature which will be permanently available to my application.
To demonstrate that...
|
by: acb |
last post by:
Hi,
I have concluded an on-demand series of webcasts forming part of a
series titled "Introduction to 2-D Video Game Development" that
took place in 2005. The URL is at
http://www.microsoft.com/events/series/msdnvideodev.mspx and the
corresponding binaries can be found at
http://www.digipen.edu/main/Webcast/Introduction_to_2-D_Video_Game_Development.
| |
by: NeedJavaHelp |
last post by:
Hello everyone, first time poster here, bear with me.
RuneScape is an online multiplayer game run by Java www.runescape.com. The game itself is run on the website and when you play the game for the first time, its files store on your pc. I've never had a problem untill its makers switched to Java Se (SUN Java). Normally, when you move to a new location / area in this game it brings up these words loading-please wait... and within 2 seconds...
|
by: whitehatmiracle |
last post by:
SOS
When i comile this program, im getting 13 errors all saying
"prompt_for_bet and get_bet are not memebers of class Player"
Where am i going wrong? Can anyone plzz enlighten me?
Thnking u all in advance
// gamble with Craps
|
by: xpun |
last post by:
hey all
So I decided to be a little ambitious over the summer and create the game of clue in c. I figured it would give my self a GOOD refresher of the language and further understand functions arrays objects etc..
Any way, I encountered a strange logic error and kinda put it to the side until now.
This code is supposed to role the die, chose the killer and deal the cards to the players depending upon the # of player. However it only...
|
by: Saser |
last post by:
Hi all bytes out there.
I have a few little problems in my program.
The program is supposed to help me to not spend too much time of my day at the computer ;)
I play a game called Counter-Strike (CS) a lot, but I'm limited to 2 ½ hours a day, and a total of 4 hours a day. I have one button in my program which starts CS, and one button that "kills" CS. The Start-button starts a timer, and the Stop-button stops it. But I want to start the...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |