Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 turing game object collision
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Gold Flame




PostPosted: Thu Jul 21, 2011 9:29 pm   Post subject: turing game object collision

What is it you are trying to achieve?
Begining the programming/coding of a video bame with combat similar too zelda a link to the past


What is the problem you are having?
I dont know how to make the characters and objects or boundaries on pathways collide
I also need the edge of the character to collide with the edge of another character as oppsed to the rectanguler edges of the transparent image colliding

Describe what you have tried to solve this problem
I havent tried it yet i just havent the foggiest clue how to do it


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
my code is just beginning. i havent yet converted it from the other code i used in highschool but heres what i have, although not entirely realevent yet

Turing:




setscreen ("graphics")              % Enter graphics mode
setscreen ("graphics:800;600")              %
setscreen ("nocursor")                      % Turn off cursor
setscreen ("noecho")                    % Do not echo keys


colorback (black)
cls

var Control : array char of boolean
var VERT, lr : int

%%%%%%%%%%%%%%%%% New Workspace "christian alchemy" %%%%%%%%%%%%%%%%%



%Controls


%%%%%%%
loop

    Input.KeyDown (Control)

 





    if Control (KEY_RIGHT_ARROW) then
        lr := lr + 2

    end if


    if Control (KEY_LEFT_ARROW) then
        lr := lr - 2
    end if

    %%%%%%%%%%%%%%%%%%%%%%%%%%
    delay (10)
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    if Control ('z') then
        put "jump" ..
        delay (10)

    else
        stanceken
    end if
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    if Control ('x') then
        kickken
        delay (100)
    else
        stanceken
    end if

    if Control ('c') then
        punchken
        delay (110)
    else
        stanceken
    end if

    if Control (' ') then
        specken
        delay (10)
    else
        stanceken
    end if


     %%%%%%% X


    Input.KeyDown (Control)

   



    if Control ('6') then
        lr2 := lr2 + 2

    end if


    if Control ('4') then
        lr2 := lr2 - 2
    end if

    %%%%%%%%%%%%%%%%%%%%%%%%%%
    delay (10)
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    if Control ('9') then
        kickkenx
        delay (100)
    else
        stancekenx
    end if

    if Control ('7') then
        punchkenx
        delay (110)
    else
        stancekenx
    end if

    if Control ('1') then
        speckenx
        delay (10)
    else
        stancekenx
    end if


%end controls


%%%%%%%%%%%%%%%%%%End new workspace "christian alchemy%%%%%%%%%%%%%%%






















%%%%%%%%%%%%%% KEN VARS
var KenStance : int
var Kenpunch : int
var Kenkick : int
var Kenspec1 : int
var Kenspec2 : int
%%%%%%%%%%%%%% END KEN VARS


var vert2, lr2 : int

lr2 := 400
%%%%%%%%%%%%%% kenx VARS
var kenxStance : int
var kenxpunch : int
var kenxkick : int
var kenxspec1 : int
var kenxspec2 : int
%%%%%%%%%%%%%% END KEN VARS





var raycler :int
var BACK : int

%%%%%%%%%MUSIC
process DoMusic
    loop
        Music.PlayFile ("darude_sandstorm.mid")
    end loop
end DoMusic

fork DoMusic
%%%%%%%%%%END MUSIC

delay (2000)
cls




%%%%%%%%%%%%%%%%%  KEN  %%%%%%%%%%%%%%%%%
KenStance := Pic.FileNew ("ken.jpg")
Kenpunch := Pic.FileNew ("KenPunch.jpg")
Kenkick := Pic.FileNew ("KenKick.jpg")
Kenspec1 := Pic.FileNew ("kenspec_1.jpg")
Kenspec2 := Pic.FileNew ("kenspec_2.jpg")
procedure stanceken


    Pic.Draw (KenStance, lr, VERT, picCopy)

end stanceken


procedure punchken


    Pic.Draw (Kenpunch, lr, VERT, picCopy)

   
end punchken

procedure kickken


    Pic.Draw (Kenkick, lr, VERT, picCopy)

end kickken

procedure specken


    Pic.Draw (Kenspec1, lr, VERT, picCopy)
delay (500)

Pic.Draw (Kenspec2, lr, VERT, picCopy)

end specken




%%%%%%%%%%%%%%%%% END KEN %%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%  KEN X %%%%%%%%%%%%%%%%%
kenxStance := Pic.FileNew ("kenX.jpg")
kenxpunch := Pic.FileNew ("KenXPunch.jpg")
kenxkick := Pic.FileNew ("KenXKick.jpg")
kenxspec1 := Pic.FileNew ("kenXspec_1.jpg")
kenxspec2 := Pic.FileNew ("kenXspec_2.jpg")
procedure stancekenx


    Pic.Draw (kenxStance, lr2, vert2, picCopy)

end stancekenx


procedure punchkenx


    Pic.Draw (kenxpunch, lr2, vert2, picCopy)

   
end punchkenx

procedure kickkenx


    Pic.Draw (kenxkick, lr2, vert2, picCopy)

end kickkenx

procedure speckenx


    Pic.Draw (kenxspec1, lr2, vert2, picCopy)
delay (500)

Pic.Draw (kenxspec2, lr2, vert2, picCopy)

end speckenx





%%%%%%%%%%%%%%%%% END kenx %%%%%%%%%%%%%%%%%


VERT := 100
lr := 100

vert2 := 100
lr2 := 400



   
   
 

%%%%%%%%%%%%%%%%%%%%%%%% X END   
   
 
end loop
%%%%%%%%%%%%%%%%%%%%%%%%




Please specify what version of Turing you are using
4.1.1.0
Sponsor
Sponsor
Sponsor
sponsor
Raknarg




PostPosted: Fri Jul 22, 2011 5:39 pm   Post subject: RE:turing game object collision

First off, you should state all your procedures and variables at the beginning.
Tony




PostPosted: Fri Jul 22, 2011 6:00 pm   Post subject: RE:turing game object collision

A good place to start figuring out collision detection is to draw out a few sketches of colliding objects on paper.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Gold Flame




PostPosted: Fri Jul 22, 2011 7:42 pm   Post subject: Re: RE:turing game object collision

Raknarg @ Fri Jul 22, 2011 5:39 pm wrote:
First off, you should state all your procedures and variables at the beginning.


yes this a old game an im disassembleing the code to make a new game
Gold Flame




PostPosted: Fri Jul 22, 2011 7:46 pm   Post subject: Re: RE:turing game object collision

Tony @ Fri Jul 22, 2011 6:00 pm wrote:
A good place to start figuring out collision detection is to draw out a few sketches of colliding objects on paper.


I just need to know how to program the main character Posted Image, might have been reduced in size. Click Image to view fullscreen.
to stop when he runs into another character or a tree or wall instead of walking right through it.

a jumping system would be helpful too cuz i dont even know where to start on that
any advice?
Zren




PostPosted: Fri Jul 22, 2011 8:12 pm   Post subject: RE:turing game object collision

Collision Detection is way easier to understand if you start out with thinking of dots on a grid, then evolving into basic shapes (rectangles and circles). In your case, I'd suggest the rectangles as they can surround your sprites more accurately.

Think along the lines that only one thing can be somewhere at once (obvious). So when you move, you make sure no other objects are there first. Walls included. Start with only two objects, link and your wall.

if (wall.x = link.x and wall.y = link.y) then link is currently at the coordinates where the wall is. Remember, you want to check where link will be before moving, not where he is right now.

Once you've got it so link can't move into that one point in space, try making the wall a rectangle. Then try having link as a rectangle.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: