
-----------------------------------
Dan
Sat Mar 06, 2004 3:41 pm

Sprites For Turing 4.x!
-----------------------------------
Check out this thing i made here:

http://www.compsci.ca/mx/index.php?page=58 


you may need to know how to import unit files to get it working. If you guys rember what Sprites where u may find this cool. For thous who do not, they are like pics but when u move them they dont deleleat the backgorup so it makes animation easer and better b/c you dont have to redraw the back gorund every few seconds.

I got a doc on there on how to uses them to so that may help explaine it a bit.

-----------------------------------
apomb
Sat Mar 06, 2004 3:50 pm


-----------------------------------
Every time i try to use sprites in turing 4.05 , it never works, even the examples in the reference don't work... why does this one? .. do you have to download the .tu file for it to work?

-----------------------------------
Dan
Sat Mar 06, 2004 3:53 pm


-----------------------------------
yes, beacue i made it all my self

u have to use my comands listed on that page.

Edit: why? b/c holth was dum and dan figgered out how to do it easly (well not that eassy but if u know what u are doing)

-----------------------------------
apomb
Sat Mar 06, 2004 4:09 pm


-----------------------------------
here is a program using your sprites, but it stops moving the sprite after a couple of keystrokes.   i did it in like 10 minutes too.

import "DanSprite.tu"

setscreen ("graphics:max;max,nobuttonbar")
setscreen ("offscreenonly")


for i : 1 .. maxx by 5
    Draw.Line (i, 0, i, maxy, 3)
end for

for ii : 1 .. maxy by 5
    Draw.Line (maxx, ii, 0, ii, 4)
end for

for iii : 1 .. maxcolor
    Draw.FillOval (maxx div 2, maxy div 2, maxcolor - iii, maxcolor - iii, iii)
end for

var chars : array char of boolean
var change : int := 2
var x, y : int := 0

var pic : int := DanSprite.newPic (1, 1, "monkie.jpg")
%var pic2 : int := DanSprite.newPic (1, 1, "pic.jpg")
loop
    View.Set ("offscreenonly")
    View.Update
    Input.KeyDown (chars)
    delay (5)
    if chars (KEY_UP_ARROW) then
        y += change
        DanSprite.movePic (x, y, pic)
    end if
    if chars (KEY_RIGHT_ARROW) then
        x += change
        DanSprite.movePic (x, y, pic)
    end if
    if chars (KEY_LEFT_ARROW) then
        x -= change

        DanSprite.movePic (x, y, pic)
    end if
    if chars (KEY_DOWN_ARROW) then
        y -= change
        DanSprite.movePic (x, y, pic)
    end if
    View.Update
end loop


EDIT : I took off the border boundaries

-----------------------------------
rizzix
Sat Mar 06, 2004 4:26 pm


-----------------------------------
hey i have my own fix for sprites in turing.. i'll post it here.. sry but the code is not documented, heh not time

here are the available functions for ur use.

Process-Safe global time slicing
 --------------------------------
 void  BeginGlobalRuntime ();
 void  ResetGlobalRuntime ();
 int   GlobalTimeSlice    ();
 void  EndGlobalRuntime   ();
 const GFX_ANIMATION, DEFAULT_ANIMATION, COMPLEX_ANIMATION


 View.Update(Area) extensions
 ----------------------------
 void GFXRadialRefresh (int x, int y, int radius);
 void GFXPolyRefresh   (int x1, int y1, int x2, int y2);


 Animation drawing extensions
 ----------------------------
 void GFXDrawRefreshPic  (Picture pic, int x, int y);
 void GFXDrawRefreshBox  (int x1, int y1, int x2, int y2, Color colr);
 void GFXDrawRefreshOval (int x, int y, int radiusx, int radiusy, Color colr);


 Static drawing extensions
 -------------------------
 void         GFXRestoreSnapshot (GFXSnapshot s);
 void         GFXDisposeSnapshot (GFXSnapshot s);
 GFXSnapshot  GFXTakeSnapshot    (int x1, int y1, int x2, int y2);
 GFXSnapshot  GFXDrawStaticPic   (Picture pic, int x, int y);
 GFXSnapshot  GFXDrawStaticOval  (Picture pic, int x, int y);
 GFXSnapshot  GFXDrawStaticBox   (Picture pic, int x, int y);


 RGB extensions
 --------------
 Color RGBi (int  r,  int g,  int b);
 Color RGBr (real r, real g, real b);



NOTE: u need turing ver 4.0.5d++ for it to work

-----------------------------------
rizzix
Sat Mar 06, 2004 4:29 pm


-----------------------------------
here is an implementation of it using some old 2d motion description library of mine,, meh. i guess there's some use if it. heh.

-----------------------------------
Dan
Sat Mar 06, 2004 6:53 pm


-----------------------------------
here is a program using your sprites, but it stops moving the sprite after a couple of keystrokes.   i did it in like 10 minutes too.


try this:


import "DanSprite.tu"

setscreen ("graphics:max;max,nobuttonbar")
setscreen ("offscreenonly")


for i : 1 .. maxx by 5
    Draw.Line (i, 0, i, maxy, 3)
end for

for ii : 1 .. maxy by 5
    Draw.Line (maxx, ii, 0, ii, 4)
end for

for iii : 1 .. maxcolor
    Draw.FillOval (maxx div 2, maxy div 2, maxcolor - iii, maxcolor - iii, iii)
end for


procedure flush
    var ch : string (1)
    loop
        exit when not hasch
        getch (ch)
    end loop
end flush


var chars : array char of boolean
var x, y := 1

var pic : int := DanSprite.newPic (1, 1, "pic.jpg")
DanSprite.setMode(pic,DanSprite.MERGE)

loop
    if Input.hasch then
        Input.KeyDown (chars)
        if chars (KEY_UP_ARROW) then
            y += 10
        end if
        if chars (KEY_RIGHT_ARROW) then
            x += 10
        end if
        if chars (KEY_LEFT_ARROW) then
            x -= 10
        end if
        if chars (KEY_DOWN_ARROW) then
            y -= 10
        end if
        DanSprite.movePic (x, y, pic)
        View.Update
        flush ()
    end if

end loop


-----------------------------------
apomb
Sat Mar 06, 2004 6:59 pm


-----------------------------------
OMG that is Amazing!!! i used the monkey picture and it looks great! I think im gonna use this to make a kick a** program!!

-----------------------------------
Dan
Sat Mar 06, 2004 7:08 pm


-----------------------------------
i think the realy question is if i could make this in a day and rizzix made one two. why is it not inculded in turing? i mean if tom can't progame that well may be we should give him this code for his next update, lol  :P

-----------------------------------
apomb
Sat Mar 06, 2004 7:15 pm


-----------------------------------
I would like to see you do that , quite thae challenge tho eh?

-----------------------------------
recneps
Sat Mar 06, 2004 8:55 pm


-----------------------------------
Haha, i read source code post before this one and suggested the very thing you said Dan :D and nice Job. show em up! Ask them to pay for compsci hosting for your contributions! :D

-----------------------------------
the_short1
Sat Mar 06, 2004 9:44 pm


-----------------------------------
yea,,,, if we started to hand over some turorials and source in exchange for compsci being hostedby holtsoft.. and getting linked from holtsoft.. . that would rip..... hacker dan you should email tom..

-----------------------------------
Dan
Sat Mar 06, 2004 9:52 pm


-----------------------------------
ya i should, lol. we are all ready liked from them tho :p on there hard to find turing likes page.

also i found a small bug in my sprite code, if u are 1/2 on the scrren and 1/2 off with a sprite and another one hits it while both are moving it can mess the back gorund a bit.

i am curlty fixing this and will post a better verson some time soon.
