Do you need tutorials ?

SGDK only sub forum

Moderator: Stef

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Do you need tutorials ?

Post by Stef » Thu Jan 11, 2018 1:41 pm

Best way to learn SGDK is looking into the provided samples (in the sample folder).
The "sprite" sample is specially useful for sprite / background basic operations =)

segaMars
Newbie
Posts: 7
Joined: Mon Nov 14, 2016 3:18 pm
Location: Sweden

Re: Do you need tutorials ?

Post by segaMars » Wed Nov 28, 2018 12:30 pm

I would love a tutorial on how to use collisions.
I have found some information on the forum describing ideas how it could be done but it would be very helpful with a sample project or tutorial, lets say two cubes (sprites) moving towards each other until they collide or perhaps a demo where multiple sprites are fiire out like bullets and collide with some other sprites.
That would be very helpful for me as collison is the next learning step for me, but I feel I got stuck here.

darkjoy2k2
Interested
Posts: 15
Joined: Tue Nov 13, 2018 8:42 pm
Location: Germany
Contact:

Re: Do you need tutorials ?

Post by darkjoy2k2 » Fri Nov 30, 2018 6:50 am

Question is not how collision is done at all, it is how to port it to sgdk in a functional way. There is no pixelperfect Sprite A collides Sprite B function, instead you should look around for general tutorials. its all math and cleverness to find the right collision for your needs.

Simple ways fitting to the power of Mega Drive are Rectangular Intersections or measure the distance (Sprite Middle + Radius to size of sprite vs each other).

The hardest part is to establish a QUADTREE if you have to handle many Sprites on screen to reduce the calls and minimize slowdown.

http://www.euclideanspace.com/maths/geo ... /index.htm
https://www.codeproject.com/Articles/30 ... ation-in-C
“No one in the world gets what they want and that is beautiful.” “You'd be amazed how much research you can get done when you have no life whatsoever.” “I created the OASIS because I never felt at home in the real world."
Ernest Cline

Miquel
Very interested
Posts: 514
Joined: Sat Jul 30, 2016 12:33 am

Re: Do you need tutorials ?

Post by Miquel » Fri Nov 30, 2018 5:31 pm

My guess is that what segaMars is really asking is how to organize, how to structure a game; from a top perspective.
HELP. Spanish TVs are brain washing people to be hostile to me.

darkjoy2k2
Interested
Posts: 15
Joined: Tue Nov 13, 2018 8:42 pm
Location: Germany
Contact:

Re: Do you need tutorials ?

Post by darkjoy2k2 » Fri Nov 30, 2018 8:55 pm

I know its a little bit off sgdk but i suggest you to look into monogame. Its c# and coming out of the discontinued Microsoft xna. It has a strong comunity, lots of samples, open source, games and stuff to study game mechanics, how concepts work etc
“No one in the world gets what they want and that is beautiful.” “You'd be amazed how much research you can get done when you have no life whatsoever.” “I created the OASIS because I never felt at home in the real world."
Ernest Cline

darkjoy2k2
Interested
Posts: 15
Joined: Tue Nov 13, 2018 8:42 pm
Location: Germany
Contact:

Re: Do you need tutorials ?

Post by darkjoy2k2 » Sun Dec 02, 2018 9:56 am

https://jonathanwhiting.com/tutorial/collision/

Another nice one collision handling tile vs sprite.

Anyone got s good one for diagonal checks?


XXXXX
X0XX
XXX
XX 1
X
“No one in the world gets what they want and that is beautiful.” “You'd be amazed how much research you can get done when you have no life whatsoever.” “I created the OASIS because I never felt at home in the real world."
Ernest Cline

Miquel
Very interested
Posts: 514
Joined: Sat Jul 30, 2016 12:33 am

Re: Do you need tutorials ?

Post by Miquel » Sun Dec 02, 2018 6:45 pm

This implementation has several big problems, that’s not how 2D games did it. Check for the article of one of the programmers of M.C. Kids for NES. That's a good start.
To obtain diagonal movement, move first the biggest axis in a recursive way, like previous text explains; I believe.
HELP. Spanish TVs are brain washing people to be hostile to me.

darkjoy2k2
Interested
Posts: 15
Joined: Tue Nov 13, 2018 8:42 pm
Location: Germany
Contact:

Re: Do you need tutorials ?

Post by darkjoy2k2 » Sun Dec 02, 2018 9:18 pm

Do you have a link for me?

I started using math formula

Code: Select all

position = sign((Bx - Ax) * (Y - Ay) - (By - Ay) * (X - Ax))

(AxAy Start of the Line, BxBy End of the line, XY Point to check)

to determinate a left (-1) or right (1) of the line. It works and im half on the way but i have a hard time, very fuzzy and lots of trial and error
“No one in the world gets what they want and that is beautiful.” “You'd be amazed how much research you can get done when you have no life whatsoever.” “I created the OASIS because I never felt at home in the real world."
Ernest Cline

Miquel
Very interested
Posts: 514
Joined: Sat Jul 30, 2016 12:33 am

Re: Do you need tutorials ?

Post by Miquel » Sun Dec 02, 2018 9:52 pm

I'm doing an action RPG, somewhat based on a Zelda game, and haven't used a single multiplication yet; no even accessing array like structures. It needs some thinking sometimes but on a "real time" game, or a game that there aren't jumps on time, multiplication isn't completely necessary. I use shifts for multiplication proposes do.

For a collision with terrain:
https://games.greggman.com/game/programming_m_c__kids/
HELP. Spanish TVs are brain washing people to be hostile to me.

darkjoy2k2
Interested
Posts: 15
Joined: Tue Nov 13, 2018 8:42 pm
Location: Germany
Contact:

Re: Do you need tutorials ?

Post by darkjoy2k2 » Mon Dec 03, 2018 4:22 am

zelda game eh? high five :-D me too...

hard to believe! mine is full of math :/

You can have a look into if you dont mind "very messy places" :P

https://drive.google.com/open?id=1jqxbX ... iTjQgLAF51
“No one in the world gets what they want and that is beautiful.” “You'd be amazed how much research you can get done when you have no life whatsoever.” “I created the OASIS because I never felt at home in the real world."
Ernest Cline

Miquel
Very interested
Posts: 514
Joined: Sat Jul 30, 2016 12:33 am

Re: Do you need tutorials ?

Post by Miquel » Mon Dec 03, 2018 7:28 pm

Didn’t say anything about maths ;). Look, if you understand a sum takes about 4 cycles and a mul wastes about 140 cycles, it’s fine if you use mul’s or not.

What I’m saying is…. we are not trying to calculate when the trains will collide in the future, but what a game actually does is moving the two trains in the present. It’s not exactly like in math class.

By jumping in space a lot of problems will occur, bullet through paper is only the first of them, and by applying patches you are only doing it worst. If you jump in diagonal is even worst, you can skip tiles altogether.

I tell you this because I have been there.
HELP. Spanish TVs are brain washing people to be hostile to me.

darkjoy2k2
Interested
Posts: 15
Joined: Tue Nov 13, 2018 8:42 pm
Location: Germany
Contact:

Re: Do you need tutorials ?

Post by darkjoy2k2 » Mon Dec 03, 2018 9:47 pm

Well, thats a statement! Is there a way to see how much load my routines throw up and how much cpu time is left until a "slowdown" happens? In xna/monogame you could measure times and guess what graphics part, gamelogic part etc. Consumes. But Mega Drive sadly has no clock :/

Btw my directional collisions work fine for now ;-D *does a floss dance*
“No one in the world gets what they want and that is beautiful.” “You'd be amazed how much research you can get done when you have no life whatsoever.” “I created the OASIS because I never felt at home in the real world."
Ernest Cline

Miquel
Very interested
Posts: 514
Joined: Sat Jul 30, 2016 12:33 am

Re: Do you need tutorials ?

Post by Miquel » Mon Dec 03, 2018 10:24 pm

What I do is put 10/20/30/40 foes at the same time and see how it escalates.

The diagonal problem usually triggers when solid tiles are also in a diagonal fashion, like this:
XO
OX
also, not all tiles have to be only solid or hollow; could be "in between" states then it's simple laughable.
HELP. Spanish TVs are brain washing people to be hostile to me.

Sik
Very interested
Posts: 939
Joined: Thu Apr 10, 2008 3:03 pm
Contact:

Re: Do you need tutorials ?

Post by Sik » Mon Dec 03, 2018 10:24 pm

darkjoy2k2 wrote:
Mon Dec 03, 2018 9:47 pm
Well, thats a statement! Is there a way to see how much load my routines throw up and how much cpu time is left until a "slowdown" happens? In xna/monogame you could measure times and guess what graphics part, gamelogic part etc. Consumes. But Mega Drive sadly has no clock :/
The HV counter gives you a loose idea by telling you where the VDP is currently rendering in the frame (the value is kind of bogus if it's in vblank, but in that case it's either too little to care or you ran into the next frame and it's obviously over 100%). You figure out how to display this in a reasonable way.

Another common trick is to change the background color as the logic runs, but that requires 1) a way to see the background color (either leave some gap where it's visible or make sure you can see border) and 2) that you aren't using raster effects (as it changes VDP state).
Sik is pronounced as "seek", not as "sick".

Miquel
Very interested
Posts: 514
Joined: Sat Jul 30, 2016 12:33 am

Re: Do you need tutorials ?

Post by Miquel » Mon Dec 03, 2018 11:48 pm

Last method is very neat Sik, the fact that you can see it visually gives it much credit.
But,
- You have to add vblank time to it
- Hope that that color is present all along the screen

Also music is very noticeable when suffers a slowdown, even very few frames.

At the end of the day all you need is some red light when frames drops, then adjust number of entities/actors/objects/scripts present and recheck difficulty.
HELP. Spanish TVs are brain washing people to be hostile to me.

Post Reply