Jump to content

  • Log In with Google      Sign In   
  • Create Account

game of thought

Member Since 22 Aug 2012
Offline Last Active Feb 18 2016 09:13 PM

Topics I've Started

Issue with turn counter

12 February 2016 - 07:21 AM

Hello, I have been writing a turn based strategy game for around the last month. It is almost done but there is one critical issue, my turn counter bugs out when clicked.

 

I have been used SDL2's event library to handle clicks and it tends to click the buttons for quite a while

 

xLpGlM0.png

 

This isn't really an issue for when the units and tiles are selected and when pathfinding is performed, but when the next turn button is clicked it goes absolutely nuts in the status window(this is from turn 1 by the way):

ToZHoL8.png

 

I am not really sure what exactly causes this, but it seems to be either the main loop or the input functions.

while( oneSideIsDead != TRUE )
	{	
		turnButtonISClicked = 0;
		oldUnitSelected = 0;
		if( turnIsChanged == 1 )
		{
			turnIsChanged = 0;
			turnNumber = turnNumber + 1;
			fprintf( stdout , "Turn : %d\n" , turnNumber );
			turnButtonISClicked = 0;
		}
		for( looper = 1 ; looper <= map->sides[ Side ]->numberUnits ; looper++ )
		{
			map->sides[ whichSide ]->units[looper]->selected = FALSE;
		}
		fprintf(stdout, "works 2\n");
		for( loopertwo = 0 ; loopertwo < map->tiles[0]->numberTiles ; loopertwo++ )
		{
			map->tiles[loopertwo]->isSelected = FALSE;
		}
		fprintf(stdout, "works 3\n");
		if( turnNumber % 2 == 1 )
		{
			Side = 0;
			enemySide = 1;
		}
		else
		{
			Side = 1;
			enemySide = 0;
		
		}
		while( turnButtonIsClicked != END_TURN_BUTTON_CODE )
		{
			if( turnButtonIsClicked != 0 )
			{
				oldUnitSelected = turnButtonIsClicked;
			}
			turnButtonIsClicked = 0;
			start = clock();
			SDL_RenderClear( renderer );
			if( time % 1 == 0 )
			{
				turnButtonIsClicked = handleMapBeenClicked( map->sides[ Side ] , map->sides[ enemySide ] , map->tiles , nextTurn , events );
				if( ( oldUnitSelected == UNIT_IS_SELECTED && turnButtonIsClicked == TILE_IS_SELECTED) || ( oldUnitSelected == UNIT_IS_SELECTED && turnButtonIsClicked == UNIT_IS_SELECTED_OTHER ) )
				{
					for( looper = 1 ; looper <= map->sides[ Side ]->numberUnits ; looper++ )
					{
						if( map->sides[ whichSide ]->units[looper]->selected == TRUE )
						{
							break;
						}
					}
					for( looperthree = 1 ; looperthree <= map->sides[ enemySide ]->numberUnits ; looperthree++ )
					{
						if( map->sides[ otherSide ]->units[looperthree]->selected == TRUE )
						{
							break;
						}
					}
					for( loopertwo = 0 ; loopertwo < map->tiles[0]->numberTiles ; loopertwo++ )
					{
						if( map->tiles[loopertwo]->isSelected == TRUE )
						{
							break;
						}
					}
					if( i != map->sides[ Side ]->numberUnits + 1 && !( loopertwo ==  map->tiles[0]->numberTiles ) && map->sides[ Side ]->units[looper]->selected == TRUE && map->tiles[loopertwo]->isSelected == TRUE && oldUnitSelected == UNIT_IS_SELECTED && turnButtonIsClicked == TILE_IS_SELECTED  )
					{
						Mix_PlayChannel( -1 , marchSound , 0 );
						moveUnit( map->sides[ Side ], map->tiles , map->tiles[loopertwo]->relativeX , map->tiles[loopertwo]->relativeY , looper );
					}
					if(looper != map->sides[ Side ]->numberUnits + 1 && map->sides[ Side ]->units[looper]->selected == TRUE && looperthree != map->sides[ enemySide ]->noUnits + 1 && map->sides[ enemySide ]->units[looperthree]->selected == TRUE && oldIsSelected == UNIT_IS_SELECTED && turnButtonIsClicked == UNIT_IS_SELECTED_OTHER )
					{
						Mix_PlayChannel( -1 , shootSound , 0 );
						defendingSideCasualties = shootUnit( map->sides[ Side ] , looper , map->sides[ enemySide ] , looperthree , map->tiles );
						attackingSideCasualties = shootUnit( map->sides[ enemySide ] , looper , map->sides[ Side ] , looper , map->tiles );
						resolveShooting( map->sides[ Side ] , looper ,  map->sides[ Side ] , looperthree , defendingSideCasualties , attackingSideCasualties );
						map->sides[ Side ]->units[looper]->selected = FALSE;
						map->sides[ enemySide ]->units[looperthree]->selected = FALSE;
					}
				}
			}
			if( events->type == SDL_QUIT )
			{
				*success = FAIL;
				return;
			}

and here is the relevant input code for the turn button:

fprintf( stderr , "Checking if the button is pressed....\n" );
	if(SDL_HasIntersection( mouseDimensions , &( button->dimensionsAndSize ) ) == SDL_TRUE )
	{	
		return SUCCESS;
	}
	else
	{
		return FAIL;
	}            
	return NULL_INPUT_VALUE;

If you need anything else to help you figure this out please don't hesitate to ask. This is at this point the only thing really holding me back and I am not sure why it does this.

 

Thanks a lot.


Can you review my code?

10 May 2015 - 05:00 PM

It is a text based zombie game in PDcurses, although could be easily converted to ncurses or regular curses. Here: clicky

 

If you can't get it to compile and have the libraries go into main.h and change the curses include as you may have it installed in a different ways.

 

I am aware of some issues that exist in the code, although they will not be fixed for a while:

1) There is no detection for anything going out of bounds

2) Zombies spawn on top of players and pits, pits on players, often either makes the game easier or instant game over.

 

 

 

Please provide comments on primarily on source code of the game primarily, and you can read some slapped together documentation in LaTeX, HTML and man pages.

 

Thanks


ASCII Enthusiasts game and programming jam

27 May 2014 - 10:42 AM

It has been a while since I have been on this forum (the better part of two years I believe) but I have come back to talk about my newly formed Game/ programming jams called ASCII enthusiasts.
 
 
The main theme of this jam is the usage of ASCII/ANSI and text based graphics to create programs only. The first competition, know as the 72 hour competition on the website, consists of a 72 hour jam to create something in the flavour of a console or terminal program but without It having to be run in the terminal. The other one, which is 10 days, is a more pure console affair and should be better for beginners as you won't be rushing around.

The 72 hour version will be from the 25th June to the 28th June while the 10 day version is from the 1st July to the 10th july.
 

We have a basic site here : click
Thanks for reading

Can somebody critque my youtube channel in a constructive manner

23 July 2013 - 06:34 PM

I was a regular on this forum and stopped posting because i learned a programming language and found my own way in terms of apis etc.. Anyway, i would like to request something of you.

I started a youtube channel a while ago and started uploading a week ago and i wondered if you could provide some constructive critism of a youtube channel. I can change almost anything save the following:

- my voice, its a bit high but hopefully not particually annoying

- what i am currently doing, i will not discontinue my DF lets play or C tutorials


Other than that go nuts, as long as it is constructive

It would also be useful to see the positives so i can play to them

Some helpful info on the channel:

- It is all unscripted and during the video(save the review)

- some are quite long


Thank you all in advance.


Link: http://www.youtube.com/user/fusiongamesstudios

Null character, PDcurses

16 June 2013 - 04:37 AM

Hello, i have recently been writing a roguelike in C99 and i have a problem when writing this game, one of my items is forever null regardless of what i do. I am quite new to C so the solution may be obvious but i can't see it, i have tried tweaking some of the assignment loops but nothing seems to happen

 

 

if you want to see the error a screenshot is attached.

 

how my assignment essentially works by using the map definition to assign items to positions based on the following things

 
while(i < MAP_ARRAY_SIZE_X)//80
{
while(j < MAP_ARRAY_SIZE_Y)//25
{
itemdecider = rand() % 50 + 1;
definefloor(&map[i][j], i , j);//defines the thing
if(map[i][j].blocked == false && itemdecider == 5 && itemcounter < 20)
{
defineitem(&items[itemcounter], i , j);//this defines the item of course
 
itemcounter++;
}
j++;
}
j = 0;
i++;
 
}
i = 0;

the item array is 20 across(hence 0 - 19  in the array) so i don't quite know what is causing this as the draw function works in the same way

 

 

ask for any other information if you need

 

Thanks for your time 

 

if you want the source you can get it here: https://github.com/gigaraptor/The-Third-Rogue

 

PS: it is odd as this only happens once in 4-5 executions of the program


PARTNERS