Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 How can i delay something specific?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
basharious




PostPosted: Sat Jan 21, 2006 4:56 pm   Post subject: How can i delay something specific?

Hiizz guys...i'm totally new to this website but it really helped me in my final project...
anyhoo...i need help in my game..it's a shooting game...2 players...planes shooting at one another.

I need to delay the pic i'm loadin for shooting ( The shot itself)..so it won't look one line...i wanna do that without delayin the whole program and without using a process coz it didn't work well Sad ......

if i can get this to work everything else is easy....thanx alot in ahead.....
Sponsor
Sponsor
Sponsor
sponsor
Delos




PostPosted: Sat Jan 21, 2006 5:57 pm   Post subject: (No subject)

Welcome. Glad we could have been some help.

Please post some code and/or a more descriptive account of what you are experiencing and what you would like to do. Always useful!
basharious




PostPosted: Sat Jan 21, 2006 8:05 pm   Post subject: (No subject)

That's the code of the game....pretty small but yeah...and the pix
basharious




PostPosted: Sat Jan 21, 2006 8:08 pm   Post subject: (No subject)

That's the code of the game....pretty small but yeah...and the pix...What I want is to get the shooting going right....i haven't done the second player yer neither the collisions(which both i can do) coz i'm stuck at this shooting....when i press CTRL which is the shooting button 2 lines show up on the screen and i wat i want is to make it look like a shot.....i don't know if my code isn't efficient enough to do that? or do i have to use another method for movement...?

thanx alot
Delos




PostPosted: Sat Jan 21, 2006 9:09 pm   Post subject: (No subject)

Your problem is that you've used a for loop in your main loop. When it gets to the shooting part, it has to complete the entire for loop before it updates the screen.
What you'll need to do is think a little more Object Orientedly. Nothing too complex yet, no need for classes (despite how useful they'd be).
To start things off, you'll need to create records for your different objects (aeroplanes, shots, players). A key component in the animation of the shots will be to create some sort of 'counter', which will determine how far the shot will move.
For instance, if the counter is 35, and for each iteration of the loop you subtract 1 from the counter, the shot will move 35 units in the specified direction. By having this sort of value implicit in the shot itself, you can loop through all commands (Input, Drawing, etc) while still maintaining the illusion of animation.

Read the Tuts on records for a description of how they work.
You'll want a seperate procedure (hopefully one with parameters) with which you'll draw all of your objects.
In your main loop, you'll want one draw command (you'll call your draw procedure) followed by the only View.Update you will have. This way, each frame gets drawn (including all objects in it) before the screen is updated.

Good call on removing the processes from your proggie. They tend to complicate matters.
You Input.KeyDown() if statements need not be seperate. Chances are, actually, that you'll want them in one if statement instead. (Perhaps the shooting could be seperate, but that's up to you to experiment with).

In the future, please zip or rar your files before posting if you have more than one file to post.
basharious




PostPosted: Sat Jan 21, 2006 10:56 pm   Post subject: (No subject)

Thanx alot that was really really helpfull....i got the records stuff going and it was a brilliant idea.....

i have a question though.....why do i need parameters for my drawing proc??

and the counter thing...so the value would change as the plane moves or something else...??...

i'm really glad i found ur website it was a great help..espically with my summative due in 3 days...hope i can get to ur level...Pro programmers Very Happy
Delos




PostPosted: Sat Jan 21, 2006 11:01 pm   Post subject: (No subject)

Paramters in this case are a matter of style, expandability and so forth. Basically, they'd allow you (if implemented properly) to specify which set of objects would be drawn. You'd need to use arrays for this.

As for the counter, imagine this:
pseudocode:

plane.X is 10
plane.count is 10

begin loop
   check for input
   if plane.count > 0 then
      plane.X increases by 1
   end
   plane.count decreases by 1
   draw all
   update screen
end


This way, the loop keeps going and the plane keeps moving.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 7 Posts ]
Jump to:   


Style:  
Search: