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 / Something wrong with my code.

Author
Message
Eminent
16
Years of Service
User Offline
Joined: 15th Jul 2010
Location:
Posted: 6th Oct 2010 00:32

It wont even show unless you rem out the lose subroutine. It usually just plays but freezes after 10 sec. You'll need DarkAI to run this. Help?


baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 6th Oct 2010 01:25
A couple of problems here:
1-You are using integers for checking the object positions
2-You are only checking the position in "X"

Change it to this and it might help:


TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 6th Oct 2010 18:13
Quote: "1-You are using integers for checking the object positions"


That's not defined, is it? I thought DBP can have variables without the hash that are floats...

TheComet

baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 6th Oct 2010 18:25
Quote: "That's not defined, is it? I thought DBP can have variables without the hash that are floats..."

Really? That's the first I've heard of it... I thought that was only if you defined it like "global pos1 as float"?

I've often had problems where I thought I'd defined something as a global float but it turned out I hadn't and it was being treated as an integer, even for simple equations such as "pos1 = 1.5 * x#". If x# was 3.0 pos1 would return value of 4 not 4.5 (as it would if pos1 was a float).

Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 6th Oct 2010 18:42
Yeah, without the # or AS FLOAT Darkbasic automatically assumes you want an integer.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 6th Oct 2010 20:03
Quote: " I thought DBP can have variables without the hash that are floats"


Yes, of course you can. Like every other type simply declare it as float.

You can be perverse and do the following if you want:



I wouldn't recommend it though.

Login to post a reply

Server time is: 2026-07-22 03:51:30
Your offset time is: 2026-07-22 03:51:30