Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Runtime Error 7006 : Object Number Illegal at line 280

Author
Message
Rikukarasuma
15
Years of Service
User Offline
Joined: 15th May 2011
Location: Ireland
Posted: 8th Jun 2011 22:53
Me and Friend are making a simple pong game but have hit a snag and are now clueless if someone would please point out our mistakes it would be most appreciated.
The project Is split up into 3 dba\'s :
Pong

Environment

Functions


Yello http://www.youtube.com/user/Rikukarasuma?feature=mhee
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 9th Jun 2011 00:15
In your MakeObjects() function, you use PlyrB by accident instead of just Plyr - so PlyrB was being created twice, and Plyr was missing.



Health, Ammo, and bacon and eggs!
Rikukarasuma
15
Years of Service
User Offline
Joined: 15th May 2011
Location: Ireland
Posted: 9th Jun 2011 02:20
Thanks For the reply Van
But theres another issue Im concerned about, The Sphere (or ball) Never seems to do anything but go back and forth,It ignores ball.yspeed altogether and i have no idea why.

Yello http://www.youtube.com/user/Rikukarasuma?feature=mhee
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 9th Jun 2011 11:58
No worries. The ball Y speed might be down to this line:

Ball.yspeed = 1 + (RND(20)/10)

I think that might be setting Y speed as an integer, maybe something like:

Ang=rnd(90)-45
Ball.xspeed = sin(rnd(Ang))
Ball.yspeed = cos(rnd(Ang))

Worth a try anyway - I can't test it right now as I'm at work, but try and use a .0 when setting a float variable, helps avoid casting issues. When an equation has no floats, it's assumed to be an integer because integers can be calculated more quickly. That code above will set the ball firing at a random angle between 45 and 135 degrees. By using trig though, you keep the velocities as 2D vectors, even when you invert them on a collision - so theres no chance for the ball to be moving anything but 1.0 units per loop - before, the movement amount was variable.

Health, Ammo, and bacon and eggs!
Rikukarasuma
15
Years of Service
User Offline
Joined: 15th May 2011
Location: Ireland
Posted: 9th Jun 2011 13:31
Unfortunately I still cant get it to work even with your code.I changed all floats to .0 format and still i get no results :/ I never thought pong would be this difficult.

Yello http://www.youtube.com/user/Rikukarasuma?feature=mhee
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 9th Jun 2011 14:56
Hehe, nothing that is worth doing is ever easy.

I'll have a look tonight, see if I can spot anything strange.

Health, Ammo, and bacon and eggs!
Rikukarasuma
15
Years of Service
User Offline
Joined: 15th May 2011
Location: Ireland
Posted: 9th Jun 2011 15:07
Cheers man and true that
I look forward to hearing from you

Yello http://www.youtube.com/user/Rikukarasuma?feature=mhee
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 9th Jun 2011 15:16
Rikukarasuma

Where does your code change Ball.y? I could see changes to Ball.yspeed but couldn't see the new value being used anywhere.

For Ball.x you have:



but I couldn't see anything similar for Ball.y

Did I miss something?
Rikukarasuma
15
Years of Service
User Offline
Joined: 15th May 2011
Location: Ireland
Posted: 9th Jun 2011 16:17
Green Gandalf I took it out because everytime i changed ball.y in collision the sphere would teleport instead of moving to it smoothly.

Yello http://www.youtube.com/user/Rikukarasuma?feature=mhee
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 9th Jun 2011 17:17
Sounds like you've answered your own question which was:

Quote: " The Sphere (or ball) Never seems to do anything but go back and forth,It ignores ball.yspeed altogether and i have no idea why."
Rikukarasuma
15
Years of Service
User Offline
Joined: 15th May 2011
Location: Ireland
Posted: 9th Jun 2011 17:33 Edited at: 9th Jun 2011 17:50
Now Im confused lol
Could you explain please ?

Yello http://www.youtube.com/user/Rikukarasuma?feature=mhee
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 9th Jun 2011 19:32
Lot's of little things changed, but have a look...



Health, Ammo, and bacon and eggs!
Rikukarasuma
15
Years of Service
User Offline
Joined: 15th May 2011
Location: Ireland
Posted: 9th Jun 2011 19:53
Thank you so very much Van!

Yello http://www.youtube.com/user/Rikukarasuma?feature=mhee

Login to post a reply

Server time is: 2026-07-11 00:36:07
Your offset time is: 2026-07-11 00:36:07