Author Topic: Bounce  (Read 11026 times)

0 Members and 1 Guest are viewing this topic.

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Bounce
« Reply #30 on: September 29, 2012, 08:18:58 pm »
Oh, nice idea :D But wouldn't it also work without the pause? ;)
It doesn't for me. Pause 8 seems to be the smallest pause that allows the code to work correctly.
why does it need pause?
Otherwise it records zero once in a while even if a key is held down, because the keypad doesn't update fast enough.




Offline dinosteven

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 194
  • Rating: +10/-1
    • View Profile
Re: Bounce
« Reply #31 on: September 29, 2012, 11:55:47 pm »
But you can save a byte in the source by using
Smaller source doesn't always mean smaller program. Sometimes it's actually larger :) (In this case it's the same size.)
How can a smaller source mean a bigger program? Can you give me an example?

Offline cooliojazz

  • Support Staff
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 619
  • Rating: +66/-9
  • I omnoms on your soul
    • View Profile
    • Unreal Phantasies
Re: Bounce
« Reply #32 on: September 30, 2012, 03:35:46 am »
A+B+C+D+E+F+G+H+I+J->K (21 bytes) compiles to 71 bytes.  Pt-On(A,B,C) (7 bytes) compiles to 146 bytes.  Some routines are bigger than others when compiled, using a couple larger routines can make the compiled program huge, even if your source seems small, while using a ton of smaller routines can keep the size down.
Spoiler For Random signess:
You can not beat my skills.
Trust me.
So don't even try.
And remember never to trust someone who says, "Trust me."

TI File Editor Progress: Remade in java like a boss. 50% we'll call it? IDK =P
Java Libraries: JIRC - 90% JTIF - 5%
TI Projects: Unreal Notator - -5000%
Nomcraft, a Bukkit mod
Some of the music I write can be found here | The Rest Should Be Here (Bandcamp)

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: Bounce
« Reply #33 on: September 30, 2012, 07:04:22 am »
Another example:

.AA
[FFFFFFFFFFFFFFFF]->Str1
ClrDraw
Pt-Off(0,,Str1)
Pt-Off(8,,Str1)
DispGraph
Pause 1800

   
.AA
[FFFFFFFFFFFFFFFF]->Str1
ClrDraw
Pt-Off(0,,Str1)
Rect(8,,,)
DispGraph
Pause 1800

Both take 68 bytes of source code but the first one takes 274 bytes of compiled code while the second one takes 386 bytes. And they both do the same thing (draw two black squares).
Why so ? Because the first one only uses the Pt-Off routine, while the second one uses the Pt-Off routine and the Rect routine, adding bytes to the executable ;)
« Last Edit: September 30, 2012, 07:06:19 am by Hayleia »
I own: 83+ ; 84+SE ; 76.fr ; CX CAS ; Prizm ; 84+CSE
Sorry if I answer with something that seems unrelated, English is not my primary language and I might not have understood well. Sorry if I make English mistakes too.

click here to know where you got your last +1s

Offline dinosteven

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 194
  • Rating: +10/-1
    • View Profile
Re: Bounce
« Reply #34 on: September 30, 2012, 09:39:34 am »
So Rect is 112 bytes larger than pt-on? Wow, that's huge. That means that I can save 112 bytes by using Pt-On for my paddle!

Offline MGOS

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 336
  • Rating: +95/-0
    • View Profile
Re: Bounce
« Reply #35 on: September 30, 2012, 09:54:24 am »
So Rect is 112 bytes larger than pt-on? Wow, that's huge. That means that I can save 112 bytes by using Pt-On for my paddle!
No, it isn't. Rect is 112 bytes large in total. The routines are only added to your program if they occur at least once in the source. So basically using two times Pt-Off will only add one Pt-Off to the program, and every times you need it, the function is called (like a subroutine).
You can save bytes by using only one type of routines (e.g. all Pt-Off or all Rect) instead of having different.

Offline dinosteven

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 194
  • Rating: +10/-1
    • View Profile
Re: Bounce
« Reply #36 on: September 30, 2012, 10:44:07 am »
Oh... that makes more sense.
I need Rect for something else anyways, so I don't need to change anything.

Do you have any ideas on how to do slow-motion? I need something that slows the ball's movement, but not the timer or the paddle. I can't change its velocity; it won't land and bounce properly if I do - that's the cost of simulating gravity more accurately. And Pause doesn't work 'cause it slows everything down. I'm stuck.

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: Bounce
« Reply #37 on: September 30, 2012, 12:54:53 pm »
Maybe add some pause in the main loop?

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline dinosteven

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 194
  • Rating: +10/-1
    • View Profile
Re: Bounce
« Reply #38 on: September 30, 2012, 01:16:03 pm »
No, 'cause the paddle and timer are processed in the main loop. I could possibly make a separate engine for the ball and tell it to run X number of times...
But then the default non slow-motion speed would be at least 2 times as fast as it is now.
And that's a lot of work to do...
Any other ideas?

Offline MGOS

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 336
  • Rating: +95/-0
    • View Profile
Re: Bounce
« Reply #39 on: September 30, 2012, 02:44:02 pm »
Simply add a counter variable, and do stuff only when the variable is dividable by 2,3 or 4 or what ever.

example

Code: [Select]
While 1   ; The main loop
C++

If C^2
This stuff is executed only every other time
End

This is always executed

EndIf getkey(15)

Offline chickendude

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 817
  • Rating: +90/-1
  • Pro-Riot Squad
    • View Profile
Re: Bounce
« Reply #40 on: September 30, 2012, 02:56:39 pm »
What you can do is add a timer for just the ball. Normally it can be set at, say 1, meaning that every time it reaches 0 (meaning every frame) you move the paddle. Later when you want slow motion, you can change the default delay to 2 or 3 so that it waits 2 or 3 frames before doing anything. If you want it to move just a little slower than everything else, set the timer to, say, 5, and run your routine to move the ball every time you update the timer EXCEPT when you reach 0. For every 5 frames that your paddle runs, the ball will be updated 4 times.

EDIT: something i do in asm all the time is use a counter and when it is divisible by 2/4/8/16 do something:
ld hl,timer
inc (hl)
ld a,(hl)
and $7 ;%111
ret z ;if bottom-most bits are 0, (meaning divisible by 8) don't update the ball.

if a = 0 it means that it is divisible by 8, it's really quick. Doing modulus 3/some other complicated number might be a bit more slow and take up more space. You could use and $3, and $1, or even and $15 depending on how much of a delay you want.
« Last Edit: September 30, 2012, 03:38:39 pm by chickendude »

Offline dinosteven

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 194
  • Rating: +10/-1
    • View Profile
Re: Bounce
« Reply #41 on: September 30, 2012, 06:29:17 pm »
Nice idea; I'll try slowing it down by a factor of 2. I have no idea what your asm code means, though...

Unfortunately, I tried messing with code too much and got stuck in an infinite loop... RAM clear... I'll try and fix the damage from a backup, then implement slow motion.

EDIT: RAM Clear wasn't to disastrous. Thank god for my obsessive backup-ing... I think I have everything back to what it was now. Time to add slowmo!

EDIT EDIT: Calc frozen now... idk why... gonna take out the batteries and re re write BOUNCE...
*sigh
« Last Edit: October 02, 2012, 09:30:28 pm by dinosteven »

Offline dinosteven

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 194
  • Rating: +10/-1
    • View Profile
Re: Bounce
« Reply #42 on: October 06, 2012, 09:30:32 pm »
Added slowmo (infinite for now), reordered some code, made the ABOUT, and fixed the 2nd issue. BOUNCE and BOUNCSRC have been updated on my 1st post.
I would've had this sooner, but RAM clears came. I had FOUR RAM CLEARS this week, each one restarting my progress. ARGGH.
3 bugs left: ball randomly deciding to skip, ball breaking the wall (less common occurrence now), and the time meter residue.

So what's wrong with my time meter? Here's what I've got:
Code: [Select]
:RectI(76,12,8,50)^r
:Rect(76,62-(T*2/15),8,T*2/15)^r
T is the amount of time left. I can't find the problem. ???

Offline dinosteven

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 194
  • Rating: +10/-1
    • View Profile
Re: Bounce
« Reply #43 on: October 25, 2012, 09:52:04 pm »
Allright, it's been a while, but now there's some updates.
Slowmo has a meter now
Buttons [Window] [Zoom] [Trace] [Graph] now are buttons for menu selection. (Maybe, not sure if I implemented it before I uploaded.)
Mode to Pause, [2nd] to unpause (it saved memory to use that subprgm)
Again, not sure if it's in the update.
Things to do:
I think I can save a few bytes by reordering code.
Path prediction
fixing the glitches
level editor?

Offline dinosteven

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 194
  • Rating: +10/-1
    • View Profile
Re: Bounce
« Reply #44 on: October 31, 2012, 08:18:44 pm »
Optimized a few bytes.