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.

2D All the way! / kinda stupid but loop dont work

Author
Message
chan
13
Years of Service
User Offline
Joined: 14th Nov 2011
Location:
Posted: 18th Nov 2011 16:57


i know its very noob but for some reason i dont know, the loop dont work. no sprites were made, but if i do it individually, that means no loop, it works fine.

any problem with my loop? --"

-Excellence deals with weak people-
Agent
20
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 18th Nov 2011 22:18
Yes. This is C code. It won't compile in DBPro, for what I might've suggested were obvious reasons.

The correct syntax for a FOR loop in DBPRO is as follows:



Note also the lack of semicolons delimiting each line - these are unnecessary in every BASIC variant of which I'm aware. Line breaks are logical elements in DBPro.

Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 19th Nov 2011 02:02
Quote: "It won't compile in DBPro"

It looks like he's using DGDK to me so I think he is after C++.

Try changing the for loop to:


Note the <=.

chan
13
Years of Service
User Offline
Joined: 14th Nov 2011
Location:
Posted: 19th Nov 2011 18:23
the "<=" means it will only work once right? so id make it ">=" ?

may i ask.. what is the difference between mine and yours?

by the way i really appreciate your help guys.

-Excellence deals with weak people-
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 19th Nov 2011 22:22 Edited at: 19th Nov 2011 22:36
Quote: "the "<=" means it will only work once right? so id make it ">=" ?"


No, as Hodgey showed you that's just the way a FOR/NEXT loop works in C++. The "<=" means less than or equal to. When you use == it won't do the loop at all... try this code snip in C++.



IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 20th Nov 2011 00:37
@chan,

It sounds like you think the for loop loops until a condition is true - it doesn't. It loops while that condition is true.

The C or C++ for loop is equivalent to a while loop. For example, apart from the variable name used (i and j), the following two loops are equivalent:


chan
13
Years of Service
User Offline
Joined: 14th Nov 2011
Location:
Posted: 20th Nov 2011 10:05
i get it now guys! thanks alot!

ive reached 2d game making but still i havvnt understood loop. XD
but i got it now.

thanks alot!

-Excellence deals with weak people-

Login to post a reply

Server time is: 2024-11-21 12:59:37
Your offset time is: 2024-11-21 12:59:37