Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - leafy

Pages: 1 ... 55 56 [57] 58 59 ... 104
841
Math and Science / Re: The Four travelers
« on: June 16, 2011, 10:17:55 pm »
I saw this problem, and I remember it was either 15 or 17 for the optimal solution. I'll try working it out again ^^

842
TI Z80 / Re: Dimension Shift: Contest Entry 2011
« on: June 16, 2011, 08:13:45 pm »
They should explode because real life

843
TI Z80 / Re: AXLE - 2011 Axe Platformer Contest
« on: June 16, 2011, 05:05:22 pm »
There should be a save function, or at the very least, an autosave function. One of the worst parts of old games was the fact that you always had to start over. ><

844
Graviter / Re: Graviter - Axe
« on: June 15, 2011, 12:17:09 pm »
I finally took the time to look at that screenie. Yeah, it's because of L2. I'll fix it soon.

845
Graviter / Re: Graviter - Axe
« on: June 14, 2011, 11:12:50 am »
It may or may not have something to do with L2 or L4. Weird shit happens when I use those free ram segments.

846
TI Z80 / Re: Contest Entry: Escape!
« on: June 14, 2011, 02:31:32 am »
Sometimes RAM is not as random as you'd like it to be :P

847
TI Z80 / Re: AXLE - 2011 Axe Platformer Contest
« on: June 14, 2011, 02:30:12 am »
Yeah, this is looking really fantastic ^^

848
Axe / Object-Based Physics Platformer Guide
« on: June 14, 2011, 02:23:02 am »
Object Based Physics Platformer Tutorial
Hey guys, it occurred to me to write a tutorial about how to make an object-based system with real physics, to be used in platformers. This tutorial will cover objects, tilemapping, moving a player character, and forces interacting with objects.

NOTE: IT'S HIGHLY LIKELY I FARKED SOMETHING UP. PLEASE TELL ME IF I DID.

Part 0: Thinking
Before you dive right in, think. What is your platformer going to feature? How is it going to be unique? What makes it stand out? Nobody wants another crap platformer claiming to be the best thing since sliced bread. Great places to start are flash games - some can be really unique and give you great ideas.

Next, start planning. Greyscale or not? How are you going to allocate your variables? Simple things like these will make a huge difference in the long run. Making sure you plan properly will save you a lot of rewrites in the future.

Part 1: The Real World
So what exactly happens in the real world? Things in the real world have three important attributes to determine their position: Their position, their velocity, and their acceleration. Acceleration is a constant value that changes the velocity by a set amount for a given amount of time. On Earth, this value is 9.8 meters per second squared. This means that for every second that passes, your velocity (in free fall) increases by 9.8 meters per second. Your velocity then increases your position, by an increasing amount each time.

Position   Velocity   Time
0      0      0
9.8      9.8      1
29.4      19.6      2
58.8      29.4      3
…      …      …

That’s good and all, but how do we apply this to a platformer?

Part 2: Inflation (The Good Kind)
Axe has a problem - that is, it doesn’t calculate decimals. So if we try to use whole-pixel acceleration values, stuff will fall way to fast for the player’s reflexes to kick in. How do we prevent this? We inflate all the position values by 256 (or some other large number, but 256 is the most optimized for Axe. I think.) What does this mean? Basically, if a position value is, say, the 56th pixel on the screen, we inflate the position value to 56*256, then divide out 256 later on. This allows us to calculate non-integral acceleration values, which is very useful in Axe.

Part 3: Object Systems
First of all, the code below will not be optimized for tutorial purposes to make it easier to understand. For more optimized code on arrays check out Deep Thought’s tutorial:
http://clrhome.co.cc/tutorials/arrays/

So let’s start! We first need a routine to set the number of objects to zero.

Code: (INITIALIZE) [Select]
Lbl IN
0→O
Return

This is vital because if you don’t do this, you might end up with a For( loop that will last for a while. And you don’t want to have to pull your batteries. Next, we need a routine that will add objects.
All objects have a certain number of attributes. It’s always good to plan out what attributes your object will have before actually creating this routine. In this case, our objects will have 5 attributes: x position, y position, x velocity, y velocity, and size. You can add others as you see fit; in Graviter, I added attributes for gravity direction, gravity lock, and whether or not the object is held or independent. Tag had just a held attribute. Since this is just a basic tutorial, we’ll go with the basics.
In regards to size, we’re going to assume all objects are square boxes. You might have to get creative with spriting, but it saves us space and coding in the long run. You can make the height and length different in the future, but this tutorial won’t cover that.

Code: (ADD OBJECT) [Select]
Lbl AO
O+1→O*10-10+L₁→r6 //This line helps us not have to keep writing O*10-10+L₁ over and over again.
r1*256→{r6}r //The r after {r6} is the superscript r, located under angle (2nd+Apps).
r2*256→{r6+2}r
0→{r6+4}r
0→{r6+6}r
r3*256→{r6+8}r
Return

Notes: r1 is initial x position, r2 is initial y position, and r3 is size.
We use the superscript r to write to two bytes. This lets us go up to 65536 instead of 256 for just one byte. If you don’t get that, don’t worry.


Optimized using Deep Thought’s method, it would look like:

Code: (ADD OBJECT) [Select]
Lbl AO
r3*256→{0→{0→{r2*256→{r1*256→{O+1→O*5-5+L₁}r+1}r+1}r+1}r+1}r
Return

So. We have a routine to add objects. Now, we’re going to update them, in a glorious shower of awesomeness. Before we start, however, there’s something I should point out. There are a lot of ways to do hit detection. Depending on how your game is going to be run, you’ll want to choose one to suit your needs. If you want some tiles to be solid graphically but not detectable to the object, you’ll want to go with pointer or byte-masking detection. One of the fastest and easiest ways, however, is pixel detection. That’s what I’m going to demonstrate in this tutorial, and I’ll attach some additional code explaining the other methods.

Pixel detection does have some drawbacks, however. For example, it is difficult (though not impossible) to have tiles that are graphically solid.

We will now create the subroutine that will cause all the objects to become affected downwards by gravity.

Code: (UPDATE OBJECT) [Select]
Lbl UO
For(r5,1,O)
r5*10+L₁→r6
{r6+6}r+1→{r6+6}r //Increments the velocity by 1 for every frame. Inflated by 256, +1 for the velocity is kinda slow. I’d go with 4 or 5.
{r6+2}r+{r6+6}r→{r6+2}r //Adds the velocity to the positional value
End
Return

Alrightttt! Wasn’t that simple. If you run this code (Which I don’t recommend) it won’t look like it’s doing anything. Which is because we still need the main program, which will call all the subroutines in the order we want them.

We’re going to want something in the following order: Generate a map, initialize values, then have the code where the game is running. Something like:

Code: (PSEUDOCODE LAYOUT) [Select]
sub(MAP)
sub(IN)
While 1
//Run game code, e.g. sub(UO),etc
End

849
TI Z80 / Re: Tag
« on: June 14, 2011, 12:37:27 am »
66 bytes? Pshaw. I don't think there's a text writing routine to back buffer anyways.

850
TI Z80 / Re: Tag
« on: June 14, 2011, 12:31:41 am »
Okay triple post! I've fully fixed the box glitch where boxes would get stuck in walls/floors and not react properly to bouncy gel, and I've implemented the transparent pause screen.


851
TI Z80 / Re: AXLE - 2011 Axe Platformer Contest
« on: June 14, 2011, 12:21:36 am »
Put AxesOn after the Axiom(CRABCAKE)

852
ASM / Re: Texture drawing
« on: June 13, 2011, 08:18:17 pm »
Oh you said polygon. Never mind.

853
ASM / Re: Texture drawing
« on: June 13, 2011, 08:12:29 pm »
Look for wolfenstein castle.

EDIT: http://www.ticalc.org/archives/files/fileinfo/277/27767.html

Hella awesome.

854
Axe / Re: Fast scroll to bottom of code editor
« on: June 13, 2011, 08:06:54 pm »
Nope that ain't handy. People will forget to send those files with the game file via the link. They will all ask me for help. Thats kinda annoying.
By the way: It takes a while to find the sub( command in the archive.

2nd+mem+"t"+up twice.

855
ASM / Re: Texture drawing
« on: June 13, 2011, 06:59:59 pm »
So is this just a horizontal engine? No looking up or down?

Pages: 1 ... 55 56 [57] 58 59 ... 104