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.

Newcomers DBPro Corner / 640x480 but its 430??? weird

Author
Message
TheMaster80k
21
Years of Service
User Offline
Joined: 11th May 2003
Location:
Posted: 16th May 2003 06:11 Edited at: 16th May 2003 06:15
hey take a look at this code


look at this line:
if downkey() = 1 and y1 < 430 then y1 = y1 + step#
if i change the 430 to 480, the box will move out of the screen? weird

btw any one knows anything about a loop in a loop?

thx for any help u can give

Dark Wolf
21
Years of Service
User Offline
Joined: 21st Apr 2003
Location: Shadows
Posted: 16th May 2003 07:43
well I am still learning to program...the first part i am not sure but to the loop depends on what you want to do the loop becuase theres 2 diffrent ways.:
1)looping sounds animations music
EXO
your commands
load music "directory.mp3",1
loop music 1
your commands
LOOP
2)do a loop inside a loop
EXO
commands
commands
DO
commands
LOOP
commands
LOOP

Dark Wolf
21
Years of Service
User Offline
Joined: 21st Apr 2003
Location: Shadows
Posted: 16th May 2003 07:48
well that didnt come out right let me try it again

Sephnroth
22
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 16th May 2003 08:09
Well i didnt check your code yet, but im guessing your sprite/image/box whatever is 50 pixels high and that when you specify its x/y co-ordinate you plotting it from the top left of that graphic, so 430 + 50 = 480, but allowing the block to go streight down to 480 hides it for the same reason ^^ make sense?

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 16th May 2003 15:25
The "430" Thing...Sephnroth is right, you haven't accounted for the height of the box.

Looping...

The term you're looking for is nesting. You can nest several loops, If statements, etc inside one another. You'll find that every program you write will require this at some point. For example, to read every element of a 10 x 10 matrix, check the source button...

Thanks in advance.
All the Best,
StevieVee
TheMaster80k
21
Years of Service
User Offline
Joined: 11th May 2003
Location:
Posted: 16th May 2003 19:24 Edited at: 16th May 2003 20:52
thx to all of u it makes sense now

but how do i continue from a loop?

btw if i use a loop iside a loop, the main loop will stop doing what it dos


try it out, and now u cant move the 2 boxes

but if u remove the inside loop u can again move the boxes

LREM 8888
21
Years of Service
User Offline
Joined: 15th Mar 2003
Location: United Kingdom
Posted: 17th May 2003 00:04
That's because DB1.13 is only single threaded, and I think you're missing the point of loops-inside-loops...

An orange can't be a tomato but a tomato can be orange...
TheMaster80k
21
Years of Service
User Offline
Joined: 11th May 2003
Location:
Posted: 17th May 2003 03:25 Edited at: 17th May 2003 03:26
i am? im using dbp.

then how is done?

btw can some tell me how to make a stripe move around?

sorry for all my noob questions but i just wanna learn.
and since there is no place that tells me how, i ask

Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 17th May 2003 12:06
DB Pro or classic are single threaded, you need loops in games to make them check the same thing over and over again, programs in db do one instruction at a time then hop to the next one, by doing this realy quickly it looks like everything is happening at the same time, for example you might have a loop that checks for players,monsters and bullets that is something like this

do
update_player
update_monster
for i=1 to 10
if bullet(i)=1 then move object 1,1 else check_disabled
next i
loop

the first part (the DO part of the do-loop) sets up an endless loop, then you go to the routine that updates the player, then the monster, and then you start a loop to check any of ten bullets, are they active and if not then disable them so you don`t try to update their position, once you checked all ten bullets in that loop then it ends at next i, and then you go back to the start of the endless loop and do everything over again, update player and monsters, move bullets etc, everything in a program runs in the MAIN GAME LOOP the main game loop is where everything that happens in the game is controled, note that in the for next loop the bullets only get their position updated and checked the once, if nothing has happend to them then they will update the next time round and keep getting updated every time until they come to an end or hit something, (there is no collision detection in that loop though), think of a program as a workman who you give one instruction at a time to, to get the effects you want you have to give the instructions in such a way that everything to handle the game gets done in the correct order and he doesnt spend too much time on any one task, since that would make the game run jerky, look at the amount of code in the examples for an idea of how many instructions you can run per loop and still keep the games speed up, cheers.

Mentor.

David T
Retired Moderator
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 17th May 2003 13:27
Quote: "btw can some tell me how to make a stripe move around?"


Sure can! Use the arrowkeys to move (see attached code). The code should be easy to understand.

You are the th person to view this signature.
Programmers don't die, they just Gosub without return....
TheMaster80k
21
Years of Service
User Offline
Joined: 11th May 2003
Location:
Posted: 17th May 2003 21:59
thx both of u but david89 that i did know i need to know how to make it move around my screen by it self, and if it hits my box i need it to move in an other direction.

David T
Retired Moderator
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 17th May 2003 22:04 Edited at: 17th May 2003 22:19
Pong is this? I'll see what I can do

edit: I've tried but I can't get the bouncing right You may want to try and use SIN() and COS() to extrapolate movement, though.

You are the th person to view this signature.
Programmers don't die, they just Gosub without return....

Login to post a reply

Server time is: 2024-11-24 14:24:02
Your offset time is: 2024-11-24 14:24:02