Learning and messing around

The Partridge Family were neither partridges nor a family. Discuss.
SunTroll
Posts: 22
Joined: April 19th, 2019, 8:25 pm

Re: Learning and messing around

Post by SunTroll » February 2nd, 2020, 4:55 pm

Finished rewatching the beginner and made the game so I will move to intermediate now. (Also made sure I liked all the videos there were few I missed.)

Anyway here is the game ballShooter source
This time I'm fairly happy how it turned out. Probably first game I made that I kinda enjoy playing (Would still need lot of work to make it good but the basic concept works (well it's just a shmup)). Also turned out to be fairly challenging to beat (at least for me).
Controls come with the game as usual.

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Learning and messing around

Post by chili » February 8th, 2020, 7:29 am

Seems like you got a few mechanics coded up nicely there. Could definitely be worked into a more polished little game.

Not sure how it's supposed to be beat tho. Maybe some feedback on when you're doing damage to the enemy or on what the actual goal is.
Chili

SunTroll
Posts: 22
Joined: April 19th, 2019, 8:25 pm

Re: Learning and messing around

Post by SunTroll » February 8th, 2020, 8:17 pm

Yeah there is a no way to tell enemy hp but you just keep shooting him until he dies.

Did you manage to get him to switch phase (core turns green)?



General tips:
1st. use bombs a lot!

2nd. slow time can be nice but would need indicator (you can fuck up if you expect it to slow down and it doesn't).

3rd. teleport is kinda meh since in the second phase you (or at least I) can't take your eyes of your character and

4th. this also means that you just let your mouse rest on the enemy (the aiming thing would need to get scraped it seemed like nice idea but you just don't have time to look where you are aiming).

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Learning and messing around

Post by chili » February 9th, 2020, 7:24 am

I wasn't even sure if what I was doing was what was intended (if the big ball in the center takes damage or not) so i didn't try that long :D
Chili

SunTroll
Posts: 22
Joined: April 19th, 2019, 8:25 pm

Re: Learning and messing around

Post by SunTroll » February 14th, 2020, 8:42 pm

Fibunator

Code: Select all

#include <conio.h>

void Print(const char* s)
{
	for (; *s != 0; s++)
	{
		_putch(*s);
	}
}

void Read(char* buf, int size)
{
	const char* const end = buf + size - 1;
	for (char c = _getch(); c != 13 && buf < end; buf++, c = _getch())
	{
		_putch(c);
		*buf = c;
	}
	*buf = 0;
}

int Str2Int(const char* s)
{
	int sum = 0;
	for (; *s >= '0' && *s <= '9'; s++)
	{
		sum *= 10;
		sum += *s - '0';
	}
	return sum;
}

void ULongLong2Str(char* s, unsigned long long convert)
{
	if (convert == 0)
	{
		*s = '0';
		s++;
	}
	else
	{
		unsigned long long divisor = 10000000000000000000;
		while (convert / divisor == 0)
		{
			divisor /= 10;
		}
		for (; divisor >= 1; s++, divisor /= 10)
		{
			const char temp = char(convert / divisor);
			*s = temp + '0';
			convert -= temp * divisor;
		}
	}
	*s = 0;
}
unsigned long long Fibonachitor(int n)
{
	unsigned long long last = 0;
	if (n == 0)
	{
		return last;
	}
	unsigned long long cur = 1;
	if (n == 1)
	{
		return cur;
	}
	n--;
	do
	{
		const unsigned long long temp = last + cur;
		last = cur;
		cur = temp;
		n--;
	} while (n > 0);
	return cur;
}

int main()
{
	Print("What positeve fibonachi number do you want? ");
	char writeFibAt[3];
	Read(writeFibAt, sizeof(writeFibAt));
	int fibAt = Str2Int(writeFibAt);
	if (fibAt > 93)
	{
		Print("\nMax value is 93.");
	}
	else
	{
		unsigned long long fibNumber = Fibonachitor(fibAt);
		char fibPrint[21];
		ULongLong2Str(fibPrint, fibNumber);
		Print("\nThe fibonachi number ");
		Print(writeFibAt);
		Print(" is: ");
		Print(fibPrint);
	}

	while (!_kbhit());
	return 0;
}
Seems to work didn't test that much.

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Learning and messing around

Post by chili » February 15th, 2020, 5:54 am

Is this from the Intermediate series? :D
Chili

SunTroll
Posts: 22
Joined: April 19th, 2019, 8:25 pm

Re: Learning and messing around

Post by SunTroll » February 15th, 2020, 5:47 pm

yep tut 3 c-string homework

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Learning and messing around

Post by chili » February 18th, 2020, 1:00 pm

Good to hear that Microhard fixed the conio.h stuff
Chili

SunTroll
Posts: 22
Joined: April 19th, 2019, 8:25 pm

Re: Learning and messing around

Post by SunTroll » February 18th, 2020, 10:53 pm

This seems to work but I'm curious why I get in.fail() instead of in.eof()?
github link
edit: Probably should also say that I'm talking about the loading file part.

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Learning and messing around

Post by chili » February 25th, 2020, 1:53 am

I mean, both flags will be set. It is not either or. But since your if...else if chain has the fail check coming first, you'll never reach the eof one.
Chili

Post Reply