c# - how to pass information from one class to another -


i using function take states of both classes how should generate function, right i'm doing

 if((b1.fxmin>s.xmin&&s.ymin==b1.fymax)&&b1.fxmin<s.xmax&&s.ymin==b1.fymax))   {      collides=true;     b1.isfiring=false;   } else if((b1.fxmin>s1.xmin&&s1.ymin==b1.fymax)&&b1.fxmin<s1.xmax&&s1.ymin==b1.fymax))  {    collides1=true;    b1.isfiring=false;  } 

in project bullet hit spider , if collides spider vanish, b1 object of class bullet , s1 , s spiders.

i have 7 spiders in game , have created 7 collides variable , 7 if statements means when ever increase spider need add collide variable , if statement

i tried in bullet class couldn't succeed. how should pass spider object bullet class?

you can pass spider bullet class follows:

// bullet.h class spider;  class bullet {   ...   bool iscolliding(const spider &s); }  // bullet.cpp #include "spider.h" // or whatever header you're using. ... bool bullet::iscolliding(const spider &s) {   // collision logic } 

you can call function main doing:

if(b1.iscolliding(s1)) {   // something. } 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -