This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's z80 & ez80 Assembly subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. Z80 & 68k Assembly => z80 & ez80 Assembly
Author Message
MaxVT103


Member


Joined: 24 Aug 2003
Posts: 109

Posted: 26 Oct 2003 08:55:32 pm    Post subject:

Does anyone know how to make something follow a line, but show the intervals from start to finish? Like drawing a sprite at those intervals.

Donald
Back to top
Justin W.
Shattered Silence


Advanced Member


Joined: 24 May 2003
Posts: 429

Posted: 27 Oct 2003 11:45:27 am    Post subject:

It is easy to move a sprite or object across the screen in a linear fashion yet I do not understand what you mean showing the intervals. In what sense are you wanting to show the intervals.

Please elaborate on the topic so I can give a better reply.
Back to top
MaxVT103


Member


Joined: 24 Aug 2003
Posts: 109

Posted: 27 Oct 2003 11:37:06 pm    Post subject:

Ok, normal linear motion is easy when you have a set slope. The problem I'm facing is I'm making a hockey game for calc and I've tried writing a routine that will shoot the puck into one of the goals from almost anywhere on the screen. The problem comes in when trying to draw the puck moving along a linear path. So when you shoot the puck you not only have the puck go into the goal but you see it as its going to the goal. Thats what I ment by linear motion. The same principles are relevant when trying to pass the puck to another player. Hopefully that will make it easier to understand what I ment.

Donald
Back to top
sgm


Calc Guru


Joined: 04 Sep 2003
Posts: 1265

Posted: 28 Oct 2003 02:39:12 pm    Post subject:

You will want to scale down the deltas by some appropriate number.
Back to top
MaxVT103


Member


Joined: 24 Aug 2003
Posts: 109

Posted: 28 Oct 2003 06:20:21 pm    Post subject:

Yeah, I figured that out. I knew that I had to write a routine to first get the width and height between the two points. So I wrote one. But then I also needed the intervals at which it would change along the line. So I wrote that, but I wasn't sure if that was correct or not. With that I tried to write the routine to get it to draw a sprite along those intervals and have it change at the appropriate spots. Thats where I got lost and everything screwed up. Heres the code I tried to make


Code:
interval_change:
   ld a,(puckshotytracker);loads the current number of incriments drawn
   ld b,a;allows for comparing b
   ld a,(puckshoty1);loads the virtical interval value
   cp b;checks to see if that value has been met
   jp z,x_interval_change;if the value has been met it jumps to the x_interval part and begins to draw that
   jp y_interval_change_down
   ret
y_interval_change_down:
   ld a,(puck_y);loads the y cor of the puck
   inc a;increases it 1 time down the screen
   ld (puck_y),a;loads the value back into the y cor
   ld a,(puckshotytracker);loads the y tracker into a
   inc a
   ld (puckshotytracker),a;increases it so that it can be compared to the value from earlier on
   ret;returns to the program so the rest can be drawn again
y_interval_change_up:
   ld a,(puck_y);loads the y cor of the puck
   dec a;decreases it 1 time down the screen
   ld (puck_y),a;loads the value back into the y cor
   ld a,(puckshotytracker);loads the y tracker into a
   inc a
   ld (puckshotytracker),a;increases it so that it can be compared to the value from earlier on
   ret;returns to the program so the rest can be drawn again
y_interval_no_change:
   ld a,0
   ld (puckshotytracker),a;increases it so that it can be compared to the value from earlier on
   ret;returns to the program so the rest can be drawn again

x_interval_change:
   ld a,(puckshotxtracker);loads the current number of x incriments drawn
   ld b,a
   ld a,(puckshotx2);loads the maximum allowed to be drawn
   cp b
   jp z,x_interval_no_change;if the values are the same, the x interval is done drawing
   ld a,(puckshotx1);loads the interval value
   cp 0
   jp m,x_interval_change_left;if the number is negative it goes to decrease the x cor
   cp 0
   jp p,x_interval_change_right;if the number is positive it goes to increase the x cor
   cp 0
   jp z,x_interval_no_change;if the number is zero then no change in x is called
   ret
x_interval_change_right:
   ld a,(puck_x);loads the x cor to a and increases it one
   inc a
   ld (puck_x),a
   ld a,0
   ld (puckshotytracker),a;resets the y tracker to 0
   ret
x_interval_change_left:
   ld a,(puck_x);loads the x cor to a and decreases it one
   dec a
   ld (puck_x),a
   ld a,0
   ld (puckshotytracker),a;resets the y tracker to 0
   ret
x_interval_no_change:
   ld a,0
   ld (puckshotytracker),a;resets the y tracker to 0
   ret

Please realise their might be a change in here from what it origionaly was bc I tried fiddleing with it to get it to work. But I'm uterly lost now.

Donald
Back to top
sgm


Calc Guru


Joined: 04 Sep 2003
Posts: 1265

Posted: 28 Oct 2003 10:45:48 pm    Post subject:

I was going to suggest you use vectors, but after taking a cursory glance at your code I decided against it. Laughing

Last edited by Guest on 28 Oct 2003 10:46:25 pm; edited 1 time in total
Back to top
John Barrus


Member


Joined: 25 May 2003
Posts: 131

Posted: 28 Oct 2003 11:43:43 pm    Post subject:

Question: what's your scale based on? (pixels, graph coords...)
Back to top
MaxVT103


Member


Joined: 24 Aug 2003
Posts: 109

Posted: 29 Oct 2003 07:22:52 am    Post subject:

Haha, I know I'm a newby programmer. But the its based on a larger pixel coordinent system. Theirs a 192 total pixel virticaly and 96 pixels horizontaly. Vectors would be a good thing to use but I suck at programming as you can see Rolling Eyes and I'm trying to make a pretty advance game for my first one. So now if anyone feels any sympothy or justs wants me to shut up in here, please help me.

Donald
Back to top
John Barrus


Member


Joined: 25 May 2003
Posts: 131

Posted: 29 Oct 2003 02:47:44 pm    Post subject:

Well, it seems kinda simple: Calculate the slope of the line, and then make a routine that draws the rise then the run of the puck.

Hey, we're happy to help, don't feel like you have to shut up.


Last edited by Guest on 29 Oct 2003 02:48:08 pm; edited 1 time in total
Back to top
MaxVT103


Member


Joined: 24 Aug 2003
Posts: 109

Posted: 29 Oct 2003 05:36:43 pm    Post subject:

Well that makes me feel a little better, ok the slope wouldn't be to hard but my problem is I only know how to program slope on calculator for whole number, not decimals. And I don't think my routines are right. So if anyone could help me with those too I'd be greately appreciative.

Donald
Back to top
sgm


Calc Guru


Joined: 04 Sep 2003
Posts: 1265

Posted: 29 Oct 2003 09:58:59 pm    Post subject:

MaxVT103 wrote:
Well that makes me feel a little better, ok the slope wouldn't be to hard but my problem is I only know how to program slope on calculator for whole number, not decimals.  And I don't think my routines are right.  So if anyone could help me with those too I'd be greately appreciative.

Donald

How about fixed-point math. Take your standard word and consider each bit to be

15: 128
14: 64
13: 32
12: 16
11: 8
10: 4
9: 2
8: 1
7: 1/2
6: 1/4
5: 1/8
4: 1/16
3: 1/32
2: 1/64
1: 1/128
0: 1/256

So with this we can store any number between 0 and 255 with a precision of 1/256 (=0.00390625).

As an example, the number 20 would be stored as 00010100:00000000, 11.25 as 00001011:01000000, etc.

Now what you can do with this is track the decimal part of divisions and multiplications with integer mathematics. Let's see if this works:

E.g: 13 / 5 should equal 2.6

13 would be represented as 00001101:00000000. The part that might be confusing is that to divide by 5 we must consider this number to be a regular 16-bit integer, so we calculate 3328 / 5 = 665 = 00000010:10011001, which under our fixed point format would be 2 + 1/2 + 1/16 + 1/32 + 1/256 = 2 + 153 / 256 = 2.59765625, which is very close to our expected answer of 2.6. When you want to convert this number to screen pixels, just throw away the decimal part.

I hope you could understand all that. A message board isn't really the best place to describe something this complicated. Cool
Back to top
MaxVT103


Member


Joined: 24 Aug 2003
Posts: 109

Posted: 29 Oct 2003 10:11:31 pm    Post subject:

Ok, yeah. That confused me.
Back to top
sgm


Calc Guru


Joined: 04 Sep 2003
Posts: 1265

Posted: 03 Nov 2003 02:48:00 pm    Post subject:

Oh, well, happy birthday, anyway.
Back to top
MaxVT103


Member


Joined: 24 Aug 2003
Posts: 109

Posted: 04 Nov 2003 12:16:44 pm    Post subject:

Thanks Very Happy . Don't worry about this anymore. The games gonna wind up getting totaly re-written soon with my friend and I so hopefully we will be able to finish it and then all of you can enjoy in the amasing gameplay of the first hockey game for the 83 in asm.
Back to top
Display posts from previous:   
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
    »
» View previous topic :: View next topic  
Page 1 of 1 » All times are UTC - 5 Hours

 

Advertisement