• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
DominicHughes

Animation is a blight and I can't figure it out ! help :(

13 posts in this topic

Hello I'm trying really hard to listen to the advice some people give but I generally don't want to do it a way that requires more annoying irritation and or emotional pain so I've been doing animation in SDL using interger counters like so

[CODE]
int timer = 0;
timer++;

if(timer == 1)
{
FRAME= 1;
}

if(timer == 2)
{
FRAME= 2;
}

if(timer == 3)
{
FRAME= 3;
timer = 0;
}

EnemyRect = StorageRect;
SDL_BlitSurface(Enemysprite[FRAME],NULL,Screen,EnemyRect);
[/CODE]

and the problem is that everytime the code sets the timer to 0 it causes the sprite to dissappear for a few milliseconds and then shows again and repeats

and I have no Idea how to stop it from disappearing

could someone please tell me how to stop this from happening in the simplest way possible that doesn't require irritation


Thanks in Advance
0

Share this post


Link to post
Share on other sites
I understand your logic, but I don't understand how your code is structured. Is this all code in a single function? Is it the timer declaration somewhere else as a global variable and the code starting from "timer++"in a function?
1

Share this post


Link to post
Share on other sites
The timer declaration is just a int timer = 0; at the top of the cpp file as simple as that [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] and timer++ is not in a function.
-1

Share this post


Link to post
Share on other sites
Why are you adding +1 to timer if it isn't within a function like main() or update()? It doesn't make sense to update timer without those.

As far as your code goes, I guess you are simply doing this as a test and that is why you aren't doing this in an OOP friendly manner and also why your code isn't structured in any refined way -- so, basically you just loop through all three of the images and then, reaching the final one, reset to the first one? But does it do this multiple times? Or is it just the one time (as you indicated by saying: "timer++ not in a function" meaning nothing of this is in a function being continuously updated)?

Finally, what is the image you are looping through? Where are EnemyRect and StorageRect defined? Lots and lots missing here to take any wild guesses, and I'm too tired honestly to try and figure out what it could be without more info about how the rest of your program is built.
0

Share this post


Link to post
Share on other sites
The main while loop of the program contains these 3 things

1).logic
2.) draw
3.)update

the rects are declared in cpp files ofc

and timer++; is just how it looks in the code I showed


The Image is a png file loaded onto a sdl_Surface

what more do you wanna know?
0

Share this post


Link to post
Share on other sites
[quote name='DarkHorseKnight' timestamp='1328745743' post='4911129']
what more do you wanna know?
[/quote]

Post code? For instance, what's stopping you from using this:
int timer = 0;

...

FRAME = timer = (timer + 1) % 4;

Without seeing more than these lines, I can't provide any help; I can't even be sure the problem lies in the lines that you posted.
0

Share this post


Link to post
Share on other sites
sorry to hear that Ectara but the idea would be to figure out what the common causes of the problem are wouldn't it? I'm no expert so can't really say

but heres the source code

[url="http://pastebin.com/McJdnZRR"]http://pastebin.com/McJdnZRR[/url]

this is just the cpp file where the problem lies

I have changed from using if statements to using switch statements for the enemy1 timer which is where the problem lies [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] which is on line 338 +
0

Share this post


Link to post
Share on other sites
[quote name='DarkHorseKnight' timestamp='1328733428' post='4911040']
Hello I'm trying really hard to listen to the advice some people give but I generally don't want to do it a way that requires more annoying irritation and or emotional pain so I've been doing animation in SDL using interger counters like so

[CODE]
int timer = 0;
timer++;

if(timer == 1)
{
FRAME= 1;
}

if(timer == 2)
{
FRAME= 2;
}

if(timer == 3)
{
FRAME= 3;
timer = 0;
}

EnemyRect = StorageRect;
SDL_BlitSurface(Enemysprite[FRAME],NULL,Screen,EnemyRect);
[/CODE]

and the problem is that everytime the code sets the timer to 0 it causes the sprite to dissappear for a few milliseconds and then shows again and repeats

and I have no Idea how to stop it from disappearing

could someone please tell me how to stop this from happening in the simplest way possible that doesn't require irritation


Thanks in Advance
[/quote]

Wow, that's not the prettiest code I've ever seen. You need to learn how to use functions and structures, as I suggested before. It will make things much easier for you.

How is OrangeGhostKnightSurf defined? is OrangeGhostKnightSurf[0]...[5] all setup with images?
0

Share this post


Link to post
Share on other sites
This is how the code looks


[code] //SurfaceStorage.h
SDL_Surface *OrangeGhostKnightSurf[5];


//main.cpp
//////////////////
//Enemy Loading
/////////////////
OrangeGhostKnightSurf[0] = IMG_Load("ArtWork/Enemys/Idle Frame 0.png");
OrangeGhostKnightSurf[1] = IMG_Load("ArtWork/Enemys/Idle Frame 1.png");
OrangeGhostKnightSurf[2]= IMG_Load("ArtWork/Enemys/Idle Frame 2.png");
OrangeGhostKnightSurf[3] = IMG_Load("ArtWork/Enemys/Idle Frame 3.png");
OrangeGhostKnightSurf[4]= IMG_Load("ArtWork/Enemys/Idle Frame 4.png");
OrangeGhostKnightSurf[5] = IMG_Load("ArtWork/Enemys/Idle Frame 5.png");
[/code]
0

Share this post


Link to post
Share on other sites
SDL_Surface *OrangeGhostKnightSurf[5];


There's your problem. You only allocate 5 Surfaces elements in your array, yet you fill it with 6 (0 - 5 is 6 images). You need to define it with 6 elements:

SDL_Surface *OrangeGhostKnightSurf[6];

That will solve you immediate problem. Your bigger problem is you aren't using functions to break up your code into pieces, and you aren't using structure to group common components and their attributes. You're going to have one massive headache trying to deal with that.
2

Share this post


Link to post
Share on other sites
I'm going to be using classes/structures and functions in my next game project.

You have inspired me :D and thanks so much you solved my problem I can't believe how strict arrays are but thanks so much I now know to be carefull when using arrays :D
0

Share this post


Link to post
Share on other sites
[quote name='DarkHorseKnight' timestamp='1328823341' post='4911446']
You have inspired me [img]http://public.gamedev.net//public/style_emoticons/default/biggrin.png[/img] and thanks so much you solved my problem [u]I can't believe how strict arrays are[/u] but thanks so much I now know to be carefull when using arrays [img]http://public.gamedev.net//public/style_emoticons/default/biggrin.png[/img]
[/quote]

Which is why C++ has std::vectors. [img]http://public.gamedev.net//public/style_emoticons/default/wink.png[/img]

[code]int timer = 0;
FRAME = timer;

timer++;

if(timer == 3)
{
timer = 0;
}[/code]

The actual reason you never saw the first frame, is because you never actually set FRAME to 0 (at least not in the code you posted).
Further, even if you [i]did[/i] set FRAME to 0, you are also skipping over 'timer' being zero.

This is what you were doing in your original post:
[code]int timer = 0; //Timer starts off at zero.
timer++; //Timer is now 1, skipping zero.

//More code... several loops pass...

if(timer == 3)
{
FRAME= 3;
timer = 0; //Timer is now zero...
}

//Next loop...
timer++; //Timer is now 1, you still skipped zero.[/code]
1

Share this post


Link to post
Share on other sites
[quote name='Servant of the Lord' timestamp='1328825511' post='4911454']
[quote name='DarkHorseKnight' timestamp='1328823341' post='4911446']
You have inspired me [img]http://public.gamedev.net//public/style_emoticons/default/biggrin.png[/img] and thanks so much you solved my problem [u]I can't believe how strict arrays are[/u] but thanks so much I now know to be carefull when using arrays [img]http://public.gamedev.net//public/style_emoticons/default/biggrin.png[/img]
[/quote]

Which is why C++ has std::vectors. [img]http://public.gamedev.net//public/style_emoticons/default/wink.png[/img]

[code]int timer = 0;
FRAME = timer;

timer++;

if(timer == 3)
{
timer = 0;
}[/code]

The actual reason you never saw the first frame, is because you never actually set FRAME to 0 (at least not in the code you posted).
Further, even if you [i]did[/i] set FRAME to 0, you are also skipping over 'timer' being zero.

This is what you were doing in your original post:
[code]int timer = 0; //Timer starts off at zero.
timer++; //Timer is now 1, skipping zero.

//More code... several loops pass...

if(timer == 3)
{
FRAME= 3;
timer = 0; //Timer is now zero...
}

//Next loop...
timer++; //Timer is now 1, you still skipped zero.[/code]
[/quote]

He changed it in his follow up post (see his pastebin code here:[url="http://pastebin.com/McJdnZRR"]http://pastebin.com/McJdnZRR[/url])

I saw that too, but it isn't there in his pastebin code, so i didn't comment on it.
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0