Gamestudio Links
Zorro Links
Newest Posts
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, ozgur), 1,526 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19058 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 3 1 2 3
minv don't work correctly #391498
01/13/12 12:03
01/13/12 12:03

M
mercuryus OP
Unregistered
mercuryus OP
Unregistered
M



This script should exit the app if gv_dist reaches the value 22.6 but did not! (V7.86.6)

Code:
///////////////////////////////
#include <acknex.h>
#include <default.c>
///////////////////////////////

var gv_dist = 0;

PANEL* p_test = {
	digits=10, 10, "distance: %3.2f", *, 1, gv_dist);
	flags=SHOW;
}

void main(){
	
	video_set(800, 600, 32, 2);
	
	level_load(NULL);	

	gv_dist=0;

	while(gv_dist<22.6){
		gv_dist=minv(gv_dist+time_step, 22.6);
		wait(1);
	}
	
	wait(1);
	beep();
	error("OK!");
	sys_exit(NULL);
	
}



Re: minv don't work correct [Re: ] #391529
01/13/12 16:39
01/13/12 16:39
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Who can help mercuryus and make his script work?

Re: minv don't work correct [Re: jcl] #391534
01/13/12 17:26
01/13/12 17:26
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
I don't know why it wouldn't work, maybe because of some machine number inaccuracies, but this should do the trick:

while(1)
{
gv_dist += time_step;
if(gv_dist >= 22.6)
{
gv_dist = 22.6;
break;
}
wait(1);
}


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: minv don't work correct [Re: Superku] #391538
01/13/12 17:48
01/13/12 17:48

M
mercuryus OP
Unregistered
mercuryus OP
Unregistered
M



I think JCL is looking for one of these C/C++ specialists.
There's a simple clue for this (if you konw how the engine handles their constants & variables).

But not all here are pure C/C++ programmer (keep all types in mind), but maybe someone can help...

(Thanx Superku anyhow!)

Last edited by mercuryus; 01/13/12 17:53. Reason: forgotten things...
Re: minv don't work correct [Re: ] #391545
01/13/12 18:55
01/13/12 18:55
Joined: Apr 2008
Posts: 586
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 586
Austria
Thats easy, this is just a confusion of float and var.

With minv you compare two vars, but with the ">22.6" you compare two floats because "22.6" is a float constant in C. The var 22.6 is always slightly less than the float 22.6 because some decimals are cut off. That's why your comparison is always true. Only when you put a (var) before the 22.6, then you have really a var and your comparison probably works, although I would still not trust such a code.

Hope this helps. This is probably not easy to see for a beginner but you can avoid such bugs when you never assume in a comparison that different generated floats have exactly the same value. Thats one of the first things to learn in C courses.

Re: minv don't work correct [Re: Petra] #391546
01/13/12 19:24
01/13/12 19:24

M
mercuryus OP
Unregistered
mercuryus OP
Unregistered
M



Thanx PL.

So it's again not a but *sight* ;)).. - move it.

PS: you never treat me with your sarcasm.

Last edited by mercuryus; 01/13/12 21:03. Reason: addendum
Re: minv don't work correct [Re: Petra] #391679
01/14/12 20:10
01/14/12 20:10
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Originally Posted By: Petra
This is probably not easy to see for a beginner but you can avoid such bugs when you never assume in a comparison that different generated floats have exactly the same value. Thats one of the first things to learn in C courses.

Just a note here.

Since the introduction of Lite-C we "veterans" of the forums got more and more this sort of feedback.
That this is "probably not easy to see for a beginner" and "That's one of the first things to learn in C courses".

May I mention that 3DGS has been always advertised that you don't need to learn any different language?
And indeed, before Lite-C there never has been any necessity to learn anything but the engine's own language.
So, many of us "veterans" learned to program while never seen another language than C-Script and later Lite-C.
Maybe, you can now understand that telling us that we are beginners,
while we already had programed several games, or at least several prototypes,
gets an offending touch.

Thank you for your understanding! laugh

Re: minv don't work correct [Re: Pappenheimer] #391680
01/14/12 20:27
01/14/12 20:27
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
Originally Posted By: Pappenheimer
Thank you for your understanding! laugh
Well put! laugh though maybe 'Sorry for your misunderstanding!' would suit better?

Re: minv don't work correct [Re: Pappenheimer] #391681
01/14/12 20:37
01/14/12 20:37
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
Originally Posted By: Pappenheimer
Thank you for your understanding! laugh

Though the problem isn't that you should be offended but that the advertising is wrong. You can agree or disagree that type conversion and floating/fixed point precision is a beginner thing or not, outside of this little world it definitely is, since its a key concept of more advanced things =/


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: minv don't work correct [Re: Pappenheimer] #391687
01/14/12 23:22
01/14/12 23:22
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Originally Posted By: Pappenheimer
Maybe, you can now understand that telling us that we are beginners, while we already had programed several games, or at least several prototypes, gets an offending touch.


How compares experience and knowledge about game development to learning a new programming language? It's like real spoken languages in the real word.

Take Spanish and Catalan as example: a friend of mine studied German and Spanish and wanted to have a semester abroad in Barcelona, because he is very attracted to that city. The point is, that Barcelona is the capital of Catalonia, a part of Spain, with a very complicated history - long story short, Catalonia is sort of a state without nationality, people there are against the Kingdom of Spain and speak their own language. It really sounds like spanish (I can't tell the difference, though), but is different in pronounciation, grammar, etc. - but similar to French and Spanish, though.

What is the end of the story? Well, my friend had to take extra courses and it took him half a year to gain a solid knowledge and some practice in speaking/reading Catalan and he was able to go a year to Barcelona - and even though he is very into languages and very good in roman languages (he also speaks Italian), he said it was super hard to be with the boys there and understand everything; in the end his Catalan was very good, though.

What I want to express is, that even though you see lots of similarities between Lite-C and C-Script, they are not the same and you have to face that you are actually in fact a beginner - when related to Lite-C. So, no one wants to offend you by helping you at basic things - because everybody has to understand basic things first to create the most amazing games in the world, later smile

Page 1 of 3 1 2 3

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1