Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

tashaklikedi

Member Since 04 Jun 2012
Offline Last Active May 18 2013 03:46 AM
-----

Topics I've Started

visual c++ version runs differently than the exe in explorer!

10 April 2013 - 04:54 PM

Hello everyone, I have a strange issue ( noob programmer here )

Some of my game's collisions do not work when I click on the exe that is located in the "release" folder from windows explorer, but they work when I do "build and compile" from visual c++. I made sure I compiled in release mode, and the data folder is copy paste in both folders. 

I really don't understand. 


How to handle states in a fighting game?

18 February 2013 - 11:51 AM

Hi everyone, as a newbie programmer, I am trying to develop a 2D side scrolling Streets of Rage like fighting game with a lot of characters, moves, and animations. I started to learn programming 1 year ago, and I managed to have a game where I have two player controllable characters hit each other, jump to higher elevations in a streets of rage style map, etc...

 

However, since I am new to programming, and rushed enthusiastically into programming the game without any plan, my code got really messy. 

My problem is how to handle character states ( or moves ) , and their animation...

 

How I proceeded is: I have a huge switch function with states, another one with animations, another one with hitboxes for example:

 


//this is the base punch for the ninja character.
// this is the state switch function
case NINJA_BASEPUNCH:
		falsify(); // set everything to false (i.e. he cant jump while punch animation is on)
		bCanBasePunch = true; 
		enumAnimState = NINJA_AS_BASEPUNCH; //animation is set to base punch animation
		enumHitMessage = HIT_LIGHT_HI; //this will tell the enemy entity the damage type ( light ) and its position ( high )
		basePunch(); //punch function 
		break;

//once this is executed, the program will set the animation settings
//this is from animation switch function

case NINJA_AS_BASEPUNCH:
		sprite.w = 36;
		sprite.h = 36;
		iCurrentFrameCol = (bFaceRight ? 13:14);
		iCurrentFrameRow = 0;
		animation.maxFrames = 2;
		animation.setFrameRate(animation.getCurrentFrame() > 0 ? 100:60);
		break;
		}
//this is from the hitbox update function. 
case NINJA_AS_PUNCH:
		hitbox.w = groundPos.w;
		hitbox.h = 35;


 

All this is only for a simple basic punch. Now imagine how would it be if there was a big move list, big combos, stunts, etc... I need to get a better system for it, anyone who can think of a better implementation system?

 


playing multiple sound formats at the same time

12 October 2012 - 12:18 PM

Hi everyone, In the game I'm developping I'm trying to use nsf (nintendo sound format) files as music and waves as sound effects. The nsf library uses SDL_Sound. the problem is that I can never load two files simultaneously. The NSF library is not able to load two sounds at once, and when I try to load my wav files with SDL_Mixer, I can't play the NSF file.

I was wondering if multi threading would solve this...

Another issue with SDL joystick

30 September 2012 - 10:46 PM

Hi again, I ran into another problem with the joystick in SDL:

in libsdl.org, it says that the joystick has 8 directions with the hat: up, down, left, right, upleft, upright, downleft, downright. But when I press the up button, it reads at the same time up, upleft, up right. This is the same for each direction (for example, if I press left, it will read left, upleft, downleft. I wonder if this is normal, if there is a problem with my joystick, or if the problem is in my code (which is a uber simplistic program to see if I get my joystick to work).

Did anybody ran into this kind of problems? (please dont send me the LazyFoo links, because there is nothing about hats there ^^)

I need help with joystick handling

26 September 2012 - 03:32 AM

Hi, I'm trying to create a double dragon - like game, and I'm trying to implement a joystick.

The problem is that until now I programmed relative to the SDL 's keyboard event handling system, which involves the key states "keydown" when a key is pressed, and "keyup" when a key is released. But I can't find a way to do the keyup part with the SDL joystick functions.

The reason I want to use this is that when you double tap a horizontal direction key, the character runs. For that I developed a counter system, in which when I release the direction key, there is a counter that is incremented and that says that I pressed forward once.

now I will paste the code here.

this is the key release function for the left key:
[source lang="cpp"] case SDLK_LEFT: { moveLeft = false; runCounterLeft++; runCounterRight = 0; } break;[/source]

and this is the function that activates the run function:

[source lang="cpp"]void CNinja::runToggle(){ if(runToggleSwitch) // the counter is at most at 1 { if(runCounterRight == 1) { { runStart = SDL_GetTicks(); //time offset for the last released direction key runToggleSwitch = false; } } if(runCounterLeft == 1) { { runStart = SDL_GetTicks(); runToggleSwitch = false; } } } if(runStart + 200 < SDL_GetTicks()) // resetting the counter states if two taps are delayed too much { runToggleSwitch = true; runCounterLeft = 0; runCounterRight = 0; } if((runCounterRight > 1||runCounterLeft > 1)&&runToggleSwitch == false) // if the counter is not reset and if it reached 2, we initiate the run function (which will be triggered by the bool running = true) { if(SDL_GetTicks() - runStart > 500) //i'm not sure anymore but now that I see it it looks like the same as above :/ not sure if this block is necessary { running = false; runToggleSwitch = true; } else running = true; runToggleSwitch = true; runCounterRight = 0; runCounterLeft = 0; }}[/source]

first and simpler : do anyone have a more versatile alternative for this to my system?

second: how can I adapt this to the SDL joystick?

PARTNERS