Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
How Do I Code A Pic.Draw to Sense Collisions from all points of Player.
Author Message
jaki723

Posted: Mon Jun 05, 2023 5:01 pm   Post subject: How Do I Code A Pic.Draw to Sense Collisions from all points of Player.

What is it you are trying to achieve?
I'm trying to get collision for falling so that it sense all parts of the player sprite and not just two separate points like I have done. If there is a better way by using something else like a draw box or something please let me know.

What is the problem you are having?
It creates too much code if we want to input every single coordinate of the sprite. With only two points the player will fall off edges and sometimes not even sense smaller objects.

Describe what you have tried to solve this problem
I don't know what else to try to solve this problem. I don't want too much code but I can't seem to simplify it.

Please specify what version of Turing you are using
I'm using Turing 4.1.1

Player.bmp
Description:
Filesize:  1.4 KB
Viewed:  2004 Time(s)

Damaged.bmp
Description:
Filesize:  1.08 KB
Viewed:  2004 Time(s)

Level1.bmp
Description:
Filesize:  309.43 KB
Viewed:  53 Time(s)

Collision1.bmp
Description:
Filesize:  309.43 KB
Viewed:  53 Time(s)

Tiny Tim.t
Description:
Filename:  Tiny Tim.t
Filesize:  2.22 KB

scholarlytutor

Posted: Thu Jun 08, 2023 11:55 am   Post subject: RE:How Do I Code A Pic.Draw to Sense Collisions from all points of Player.

Thanks for including the code and pictures. I got the program running.

I assume you're talking about when the character falls down a pit, correct?

I see no need to have to sense all the pixels in the sprite. The only thing that matters is the y value of any of the bottom pixels. I believe Pic.Draw uses the bottom left pixel as the position where the character is drawn from

So as soon as the Y value of that bottom left pixel becomes 0 (meaning they have touched the bottom edge of the screen), they need to stop falling and you should show the damaged character (perhaps with a delay of 250-500 milliseconds) then put the normal picture back on top.

For falling off platforms, if the character is moving left, it should be their x value + how many pixels wide the character is which determines whether they fall, so they don't start to fall too early, which seems to be happening at the moment.

If I'm misunderstanding anything, please feel free to clarify.
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 2 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: