A very basic pygame sprite example. Moving a sprite with the arrow keys, could be the start of a great space game.

Member Avatar
+0 forum 0

So i'm making an rpg game with c# and xna. How can I create a simple camera that follows the player as they move? I only wish for the camera to move as the player reaches the middle of the screen. I dont require it to rotate, zoom in/out like other tutorials I have seen. Any help or suggestions would be greatly appreciated!

Member Avatar
Member Avatar
+1 forum 3

Hi, I am trying to use an image sprite for icon in my button. Following is my css class for the same. The problem I am facing is that it seems to be pulling even the neighbouring image (which might be due to bigger text on the button) Is there any way to handle this? .sprite-reset { background: url(../images/composite_image.gif) no-repeat !important; padding: 0px 0px 0px 19px !important; background-position: 0 -465px !important; width: 50px ; height: 16px; } Attaching the button screenshot herewith. Thanks in advance!

Member Avatar
Member Avatar
+0 forum 3

Hello, I need help with a menu I'm creating with a sprite image. I don't know why, but on hover it moves up what looks like 1 pixel. I have created a jsfiddle for it here: [Click Here](http://jsfiddle.net/Cgull/HrmH8/) Also, first time I am creating a jsfiddle so hope it's ok. Can someone please help?

Member Avatar
Member Avatar
+0 forum 4

I am trying to create a simple scoring function using sprite collision. I have my sprite ids defined under a seperate header and my class is in order. LEFT_SCORE is animated using a sprite sheet (obviously). int Ball::leftGoal( ) { int leftScore = 1; if (dbSpriteCollision (BALL, 12)) {++leftScore;} dbSetSpriteFrame (LEFT_SCORE, leftScore); return 0; } The output I am getting is that leftScore increases as expected and the LEFT_SCORE sprite acts appropriately... But, the score never tallies. It works only while the two sprites (BALL and 12) are actually touching. After that the value of leftScore returns to 1. I …

Member Avatar
Member Avatar
+0 forum 4

Hiya! I got rotating bitmaps working in my game using al_draw_rotated_bitmap(); Then i put animations in using al_draw_bitmap_region(); Ive found that i can either do one or the other. But i want it to animate and rotate. After looking at the allegro source to see what other functions are available and looking onlne there doesnt seem to be an allegro function that can rotate and draw a region of the sprite sheet at the same time. Am i missing it? If not how do i go about rotating an animated sprite :S Thanks in advance!

Member Avatar
Member Avatar
+0 forum 1

I've created a game , somewhat like space invaders, and it looks pretty cool , very proud of what ive done. But I'm stuck on finding a way of unit testing the collision of 2 sprites and the collision between the borders and a sprite. If anyone could point me in the right direction or has any sample code of this happening that would be great!

Member Avatar
Member Avatar
+0 forum 1

[CODE]int realX = winSize.width + (projectile.contentSize.width/2); float ratio = (float) offY / (float) offX; int realY = (realX * ratio) + projectile.position.y; CGPoint realDest = ccp(realX, realY); [_projectiles addObject:projectile]; projectile.tag = 2; [projectile runAction:[CCSequence actions: [CCMoveTo actionWithDuration:realMoveDuration position:realDest], [CCCallFuncN actionWithTarget:self selector:@selector(spriteMoveFinished:)], nil]];[/CODE] In this simple app, I am trying to make a projectile flying from the middle of the screen to wherever the user touches, and beyond, to the edge of the screen. For whatever reason, the projectile will only fly to destinations with positive x coordinates, no matter when the user presses. If you imagine an x y plane, …

Member Avatar
+0 forum 0

[CODE]int realX = winSize.width + (projectile.contentSize.width/2); float ratio = (float) offY / (float) offX; int realY = (realX * ratio) + projectile.position.y; CGPoint realDest = ccp(realX, realY); [_projectiles addObject:projectile]; projectile.tag = 2; [projectile runAction:[CCSequence actions: [CCMoveTo actionWithDuration:realMoveDuration position:realDest], [CCCallFuncN actionWithTarget:self selector:@selector(spriteMoveFinished:)], nil]];[/CODE] In this simple app, I am trying to make a projectile flying from the middle of the screen to wherever the user touches, and beyond, to the edge of the screen. For whatever reason, the projectile will only fly to destinations with positive x coordinates, no matter when the user presses. If you imagine an x y plane, …

Member Avatar
+0 forum 0

Hello, I am creating a card game and need some advice/pointers or code snipets if possible on sprite movement in the sence I need to create an action of a card been drawn from the deck. Basicly I need to make the sprite(card) move from the deck posion(x,y) to the players hand position(x,y) or from hand/deck to the waste pile, the game will consist of 4 players so the cards will be going in all directions and I can not fiqure out a formula that will make the cards move quick and smothly to their correct possitions and I cant …

Member Avatar
Member Avatar
+0 forum 5

So it's this program which isn't behaving as it should. these are the classes I'm haing problems with: [code]#ifndef _CMENU_H_ #define _CMENU_H_ #include "Vec2.h" #include "Background.h" #include "Sprite.h" #include "BackBuffer.h" class Button { public: enum ButtonState { NORMAL, //when cursor is not near the button ANIMATED //mouseover event }; Button(const char*,const char*,const char*,Vec2&); //const char* 's are the name of the bitmaps for the mask, normal image, and animated image; //Vec2 is the position on the screen virtual ~Button(void); bool Update(POINT&); //takes the curent cursor position(POINT)and changes the button state void Draw(const BackBuffer*); //draws the button protected: Sprite* image[2]; //image[0] …

Member Avatar
Member Avatar
+0 forum 3

Hi We are high school students working on a final project for our course. We are making a top down shooter type game using pygame (its kind of like boxhead), and have made made all of our game except for the ai. We really need some help with this, so if any one has any ideas on how we could go about making ai it would really help. Somethings we would like to incorporate in our AI are: -if there is no wall between and enemy the enemy shoots at the player -if the player is far enough from the …

Member Avatar
Member Avatar
+0 forum 7

Hi guys I'm writing a top down shooter game in pygame and wanted to use sprites for my object. I got a character sprite working fairly well except I have two problems. 1. When I rotate my character the point of rotation is changing. This causes a uneven rotation in my character 2. I have a problem with rotating at the same time as moving. I can rotate after I have moved in a single direction for several seconds, but as soon as change directions, I can no longer rotate until I have waited another several seconds. Here is my …

Member Avatar
+0 forum 0

I just took almost all the graphics on my website that are used often in the design and put them into a CSS sprite. Because of the varying sizes this created large area of the new image file that had nothing in them. The result of this was a new CSS sprite that was about 80KB when all the original images together were only about 48KB. I can tell how the webpage is actually loading slower now. Is it worth keeping the sprites to minimize HTTP requests? Does size matter more or the amount the server is contacted to download …

Member Avatar
+0 forum 0

Hi everyone. Well I've been trying to figure this out for a quite a long time now by looking at some examples and searching the web, reading some tutorials and so on, but I don't even know where to start yet. Can you explain to me about the sprites too and how I can use them or at least link me to a tutorial? But my main concern is how am I suppose to get the mouse click position and make the bullet travel in its direction until it disappears from the screen or it hits an object (Which I …

Member Avatar
Member Avatar
+0 forum 3

Hello does anybody know how to scale a sprite or image to fit the whole render window? at the moment i have my checkers board but its in one corner of the window and i want it to fit the window entirely would be a great help :)

Member Avatar
Member Avatar
+0 forum 3

I recently made a switch to SDL as a cross platform alternative to directly accessing DirectX or OpenGL. In an attempt to port a section of my game framework, I encounter logic errors that (to me) make absolutely no sense. In this snippet, a sprite is simply a wrapper class for an image and a collection of rectangles that makeup sub-images. [CODE] // sprite.h class Sprite { private: SDL_Surface* surface; SDL_Rect* frames; public: SDL_Surface* GetSurface(); SDL_Rect* GetFrame(int index); Sprite(SDL_Surface* surface, SDL_Rect frames[]); ~Sprite(); }; [/CODE] [CODE] // sprite.cpp SDL_Surface* Sprite::GetSurface() { return surface; } SDL_Rect* Sprite::GetFrame(int index) { if (frames …

Member Avatar
Member Avatar
+0 forum 1

I'm having a problem with a navigation map that uses javascript and CSS to shift a sprite. The sprite image is located at [url]www.eagleonedims.com/images/navmap.jpg[/url]. On each <li> rollover, I need the ENTIRE sprite shifted by 88px to account for the overlapping effect. The page in question is located at [url]www.eagleonedims.com/index2.php[/url]. If you view this page in IE, the navigation rollover works. However, it does not work in Chrome. I have not tested Firefox. NOTE: I've only setup the HOME button. Any ideas why it will not work in Chrome? It's frustrating me to say the least. Thanks in advance! Here's …

Member Avatar
Member Avatar
+0 forum 2

Hello Daniweb, I am writing a game engine in C++ with SDL, and am faced with a problem. I need to store the sprite animation coordinates for every different animation in a different array. The problem I am facing is, since I am putting the arrays in one single Player class, and there will be different players with different animations and amount of animations, how would I implement this? Is it possible to add class members dynamically? Could I load the member variables from a text file? I've been sitting at my computer for a good hour/ hour and a …

Member Avatar
Member Avatar
+0 forum 3

Hello, I know this is a very simple problem, but I am about to give up... Why couldn't I get the control keys do their job? Maybe someone whose eyes are more rested than mine can tell me. I will appreciate any help. I am dealing with pygame, and I have two images loaded on the screen when running the program. However, what I want the first image in the first sprite to do is moving around with controlled keys by me, such as, move up, left, down, and right. By the way, needless to say, I am new to …

Member Avatar
Member Avatar
+0 forum 4

The End.