Jump to content

  • Log In with Google      Sign In   
  • Create Account


black_darkness

Member Since 10 Dec 2012
Offline Last Active Feb 28 2013 03:16 AM
-----

#5016647 I have two functions that do the same thing. Which one is faster?

Posted by black_darkness on 02 January 2013 - 05:48 AM

Please read a book about C++. You are calling a METHOD (as opposed to function). A method belongs to an object. Therefore, you can access a pointer to object you are calling your method from using keyword 'this'. So you can write

 

I did read a book but I started getting confused so I started making this game so I could get some experience in order to understand the book better. This was a really helpful post thank you.




#5013026 Suggestions on my situation?

Posted by black_darkness on 20 December 2012 - 08:25 PM

Why didn't you tell us the name of the game? I am really curious which game it is.


#5012709 Some Feedback on my Multiplayer Pong Game please!

Posted by black_darkness on 19 December 2012 - 11:13 PM

I got a game up and running thanks to Ultramailman. How many more hours are you going to put into this? I think it will be fun if you make the ball increase in speed depending on the angle. ( I think that is how the original pong worked.) .


#5012701 Some Feedback on my Multiplayer Pong Game please!

Posted by black_darkness on 19 December 2012 - 10:28 PM

I had the same issue as the other two in this thread. I resolved it by dragging the lower bottom right corner and expanding window size.

I started the game but I do not know how to play. I tried pressing a bunch of random buttons but nothing happens. I do see two paddles and a ball.


#5012430 I want audio sound effects. Like Animal crossing, and Bob's Game.

Posted by black_darkness on 19 December 2012 - 07:25 AM

Hey


Thanks for the advice. I will try to come up with something. That sounds like a lot of work so it will probably be a while.


#5011982 How to distribute a game without being accused of distributing a virus.

Posted by black_darkness on 18 December 2012 - 04:41 AM

Is there any way of writing a game in c++ and distributing it without anti-virus software accusing it of being a virus? I wanted my friend to play the game I made and he said that his computer wouldn't let him open the file. It prevented him with this message -> "Your internet security settings prevented one or more files from being opened." He didn't know which virus protection he had.

Is compiling and distributing a .exe file with the game on it a bad idea? What is the best way to distribute a game?

He doesn't have a compiler or the motivation to install allegro to compile it himself.


P.S. Sorry that the topic title is worded properly. I should have named the topic "How do I distribute a game without being accused of distributing a virus?".


#5011523 I need help with vectors of vectors.

Posted by black_darkness on 16 December 2012 - 10:34 PM

mv.clear() would be sufficient to clear everything.


Thank you.

BTW. I found this code just now for visual studio compilers. src http://www.david-amador.com/2010/10/tracking-memory-leaks-in-visual-studio/

It detects memory leaks. I had a ton.
Do you recommend this as a good way for me to test for errors in the future?

#ifdef _DEBUG
int flag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
flag |= _CRTDBG_LEAK_CHECK_DF; // Turn on leak-checking bit
_CrtSetDbgFlag(flag);
#endif



#5011013 Very early alpha of a retro 2D game -- keen for community critique

Posted by black_darkness on 15 December 2012 - 01:43 PM

I thought it was fun. Is the default resolution 1080p? Or does the game dynamically size the window to match monitor resolution? I also couldn't hear anything.

I liked the gameplay. Is there a way to pick up that armor or fight the skeletons, and dogs?


#5010401 Could someone give me feedback on my algorithm?

Posted by black_darkness on 13 December 2012 - 06:01 PM

Hey Cornstalks I wrote a test and it works but It is switching 1 square too soon.

The test actually works, but you are misinterpreting the results. Square 1 is the second square of the first row, and square 8 is the first square of the second row. Both square 1 and square 8 should be red. Square 0, the first square of the first row, on the other hand, should be (and is) white.



I always thought that if you wrote a for loop it added one then ran what was inside the curly braces. oops. You were right. I wrote this test. I always did get a lot of 1 off errors.

#include <iostream>;
int main()
{
using namespace std;
for(int i=0;i<5;i++)
{
  cout<<i<<"\n";
}
return 0;
}

and this was the output.
Posted Image


#5010382 Could someone give me feedback on my algorithm?

Posted by black_darkness on 13 December 2012 - 05:14 PM

First step is to obtain the 2-dimensional coordinate of a square. For example, if k is what you call the current square is a 1-dimensional sequential index (for example you number the squares sequentially along a row, and column by column), then you can obtain the (x,y) coordinate as x=k%8 and y=k/8.

Once you have a 2-dimensional coordinate into the checker board, you can color it according to:

if(x%2 == y%2)
	red square
else
	white square


This seems like it will work thank you. I will try to implement a 2d system.


#5010381 Could someone give me feedback on my algorithm?

Posted by black_darkness on 13 December 2012 - 05:12 PM

I think you could immediately shorten that to:

// This if statement might seem kind of magical
if (((rects.size()  / 8) % 2) == 0) // if <= 16, 32, 48, 64
{
    if(j%2 == 1  )
    {
	    (*rects[(k)]).set_fill_color(Color::red);
    }
    else if(j%2 == 0)
    {
	    (*rects[(k)]).set_fill_color(Color::white);
    }
}
else // <= 8, 24, 40, 56
{
    if(j%2 == 0  )
    {
	    (*rects[(k)]).set_fill_color(Color::red);
    }
    else if(j%2 == 1)
    {
	    (*rects[(k)]).set_fill_color(Color::white);
    }
}

Yeah I kind of want to avoid another solution like this.

However, I wouldn't actually recommend the above, and if I were you, I'd do something more like:

for (int i = 0; i < rects.size(); ++i)
{
    if ((i % 2) == 0)
    {
	    rects[i]->set_fill_color(Color::red);
    }
    else
    {
	    rects[i]->set_fill_color(Color::white);
    }
}

I tried that at first but since the first square on the left is always even it made a red and white stripe pattern. So that is why I was forced to switch every time k increased by 8.


#5010373 Could someone give me feedback on my algorithm?

Posted by black_darkness on 13 December 2012 - 05:01 PM

I don't understand much of what you're doing or working with, but it looks like, without changing the logic of how you wanna paint it, you could use a for loops instead of repeating 8,16,24...64 you could make it 8 * i where i = 1,2,3...8


Here is an explanation of the goal.

I have this information for my algorithm to work with.

* current square (or k)
* j is a counter. So it changes from even to odd every turn, letting me know if current square is even or odd. (I could use k to do this and make simpler though I think)
* I have the rects.size() (This is the size of the vector)

I want to use this information to paint a checkerboard pattern. In order to do this the first 8 must have odds painted white, and evens painted red. The second 8 must have odds painted red and evens painted white. This will alternate line by line until I get to the bottom.

I couldn't think of how to do this without manually switching every time k increases by 8.


#5010361 Could someone give me feedback on my algorithm?

Posted by black_darkness on 13 December 2012 - 04:43 PM

Hello. I am writing an algorithm that paints an 8 x 8 checkerboard red, and white. However the algorithm at this moment is 87 lines long. Sadly It would be only 64 lines to individually color all 64 squares. Please give me feedback.

Here is some more relevant information. At first I tried to paint every other square red. However it looked like this. (rough illustration)
Posted Image

Now after implementing my algorithm it looks like this.
Posted Image


Variable k represents the current square. j is the counter. So I use it to run a % on in order to determine even or odd.

if(rects.size()<=8)
   {
	if(j%2 == 0  )
	{
	 (*rects[(k)]).set_fill_color(Color::red);
	}
	else if(j%2 == 1)
	{
	 (*rects[(k)]).set_fill_color(Color::white);
	}
   }
   else if(rects.size()<=16)
   {
	if(j%2 == 1  )
	{
	 (*rects[(k)]).set_fill_color(Color::red);
	}
	else if(j%2 == 0)
	{
	 (*rects[(k)]).set_fill_color(Color::white);
	}
   }
   else if(rects.size()<=24)
   {
	if(j%2 == 0  )
	{
	 (*rects[(k)]).set_fill_color(Color::red);
	}
	else if(j%2 == 1)
	{
	 (*rects[(k)]).set_fill_color(Color::white);
	}
   }
   else if(rects.size()<=32)
   {
	if(j%2 == 1  )
	{
	 (*rects[(k)]).set_fill_color(Color::red);
	}
	else if(j%2 == 0)
	{
	 (*rects[(k)]).set_fill_color(Color::white);
	}
   }
   else if(rects.size()<=40)
   {
	if(j%2 == 0  )
	{
	 (*rects[(k)]).set_fill_color(Color::red);
	}
	else if(j%2 == 1)
	{
	 (*rects[(k)]).set_fill_color(Color::white);
	}
   }
   else if(rects.size()<=48)
   {
	if(j%2 == 1  )
	{
	 (*rects[(k)]).set_fill_color(Color::red);
	}
	else if(j%2 == 0)
	{
	 (*rects[(k)]).set_fill_color(Color::white);
	}
   }
   else if(rects.size()<=56)
   {
	if(j%2 == 0  )
	{
	 (*rects[(k)]).set_fill_color(Color::red);
	}
	else if(j%2 == 1)
	{
	 (*rects[(k)]).set_fill_color(Color::white);
	}
   }
   else if(rects.size()<=64)
   {
	if(j%2 == 1  )
	{
	 (*rects[(k)]).set_fill_color(Color::red);
	}
	else if(j%2 == 0)
	{
	 (*rects[(k)]).set_fill_color(Color::white);
	}
   }



PARTNERS