Page 3 of 6

Re: Do you need tutorials ?

Posted: Thu Jan 11, 2018 1:41 pm
by Stef
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 =)

Re: Do you need tutorials ?

Posted: Wed Nov 28, 2018 12:30 pm
by segaMars
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.

Re: Do you need tutorials ?

Posted: Fri Nov 30, 2018 6:50 am
by darkjoy2k2
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

Re: Do you need tutorials ?

Posted: Fri Nov 30, 2018 5:31 pm
by Miquel
My guess is that what segaMars is really asking is how to organize, how to structure a game; from a top perspective.

Re: Do you need tutorials ?

Posted: Fri Nov 30, 2018 8:55 pm
by darkjoy2k2
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

Re: Do you need tutorials ?

Posted: Sun Dec 02, 2018 9:56 am
by darkjoy2k2
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

Re: Do you need tutorials ?

Posted: Sun Dec 02, 2018 6:45 pm
by Miquel
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.

Re: Do you need tutorials ?

Posted: Sun Dec 02, 2018 9:18 pm
by darkjoy2k2
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

Re: Do you need tutorials ?

Posted: Sun Dec 02, 2018 9:52 pm
by Miquel
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/

Re: Do you need tutorials ?

Posted: Mon Dec 03, 2018 4:22 am
by darkjoy2k2
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

Re: Do you need tutorials ?

Posted: Mon Dec 03, 2018 7:28 pm
by Miquel
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.

Re: Do you need tutorials ?

Posted: Mon Dec 03, 2018 9:47 pm
by darkjoy2k2
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*

Re: Do you need tutorials ?

Posted: Mon Dec 03, 2018 10:24 pm
by Miquel
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.

Re: Do you need tutorials ?

Posted: Mon Dec 03, 2018 10:24 pm
by Sik
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).

Re: Do you need tutorials ?

Posted: Mon Dec 03, 2018 11:48 pm
by Miquel
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.