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 / Help Please (new programmer)

Author
Message
mikimiki999
16
Years of Service
User Offline
Joined: 5th Apr 2010
Location: Warrington, UK
Posted: 5th Apr 2010 23:33
Hi, im doing a project in college and am designing a game on DB Pro. i have decided to make a 2d fighter but have come to a few problems. one of whch is trying to get both characters to move simutaniously, (i am trying to make it multiplayer). and the second problem is taking one health bar off a hit. if you could help me and maybe give me some simple coding to work with it would be greatly appricated (below is my code). Cheers

GreenDixy
18
Years of Service
User Offline
Joined: 24th Jul 2008
Location: Toronto
Posted: 5th Apr 2010 23:38
Not to sound rude or anything, But use search. There is tons on "Multiplayer" And "Health" for multiplayer. Look into darknet or multysync, Both great plugins for what you want to do.

======================================
Kira Vakaan
17
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 5th Apr 2010 23:57
I recommend using the keystate() command instead of inkey() because it allows for simultaneous key reading. You can use scancode() to get the key number to use in keystate().

This little snippet moves a sprite around using WASD. You could also make the sprite play its walking animation with each key.

As for your health bar, just call a function every loop that draws the bar. Something like this:


Hope that helps
Mnemonix
23
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: Skaro
Posted: 6th Apr 2010 00:35
off topic,

Kira, in the second snipped you posted, what is the function of the [ after endfunction. Never seen that before.

Your signature has been erased by a mod because it's larger than 600x120
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 6th Apr 2010 00:47 Edited at: 6th Apr 2010 00:49
He may have wanted to type [ /code ] but typed [[ /code ]

EDIT : Had to put spaces or it wouldn't have shown up...

TheComet

Kira Vakaan
17
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 6th Apr 2010 03:13
Oops, yeah, what TheComet said.
mikimiki999
16
Years of Service
User Offline
Joined: 5th Apr 2010
Location: Warrington, UK
Posted: 9th Apr 2010 00:21
Thanks e1 (espec Kira) i have sorted out the movement but the health bar i cant seem to get to work. can u explain it in a bit of detail on how it works and give an example of how it is used please thanks for the help again guys
Kira Vakaan
17
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 10th Apr 2010 04:25
Well in your program, you have a main loop, yes? On every loop of the program, you want to draw the health bar onto the screen with everything else, so somewhere inside your main loop you should call a function to draw the health bar. As for how my little example did that, basically I assumed you have an image of one segment of health and I drew a copy of that image for every unit of health the player has. I did that with a for loop. As the variable a counts higher, I multiply it by the width of the segment image to get the X coordinate of the place I should draw the next segment.
mikimiki999
16
Years of Service
User Offline
Joined: 5th Apr 2010
Location: Warrington, UK
Posted: 11th Apr 2010 14:12
right lol. I get how it works but actually getting it to work is another story. I really want to finish this game, I am sorry for this but if I post the code can you see where im going wrong. thankyou,
TDK
Retired Moderator
23
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 12th Apr 2010 23:44
Lol!

Can't anyone indent code properly any more?

TDK

Kira Vakaan
17
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 12th Apr 2010 23:50
Yeah, the indentation in your HandlePlayer() function is pretty screwy.

As for the health bar, I didn't see any definition of the variable PlayerHealth, so the value defaults to 0. Add something like this at the beginning of your program:
Hawkblood
16
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 13th Apr 2010 16:03
Quote: "trying to get both characters to move simutaniously"

I couldn't help but notice that noone has mentioned the "simultaniously" part of your problem.... I think you have too many do-loop's. The movement of the characters is done in two seperate functions, each with it's own do-loop. When you call the handlespidey() function, It doesn't take input from the other player. Try making a single do-loop that calls the two functions and take the do-loop's out of those functions. Try that for starters.

The fastest code is the code never written.
Kira Vakaan
17
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 13th Apr 2010 23:19
Quote: "I recommend using the keystate() command instead of inkey() because it allows for simultaneous key reading"


And if you'd read his later post, you'd see that he's already done that.
D Ogre
22
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 14th Apr 2010 04:04 Edited at: 14th Apr 2010 04:20
I personally like using joysticks for 2D fighters. Keyboard controls are fine for one player on one machine and then place each player on a different machine in a multiplayer network, which I'm assuming you're going to here eventually. But what if you wanted to play a two player game on a single machine? Keyboard input on a single machine with two players can be quite hokey. Two joysticks work quite nicely in this case, and it is completely viable now since DBPro has multi-joystick support now-a-days. That's my suggestion to you, but you can choose to do whatever you want.

I myself would design the player control code to be timer based. Firstly, to see which players attack takes presidence and would possibly be successful. Your collision system can be distance based. Simply check the XY sprite coordinates to see if an attack is effective within a given range. Secondly, check if a player's joystick input for a combo attack is completed correctly and within the specified time period alloted before the timer is reset. I've used string variables to build a combo code which can be checked against.
mikimiki999
16
Years of Service
User Offline
Joined: 5th Apr 2010
Location: Warrington, UK
Posted: 16th Apr 2010 19:13
I have declared the variable for player health. how do I program it to delete it one of the health icons, and once all the icons have been deleted to display a game over screen.

Login to post a reply

Server time is: 2026-07-26 14:30:54
Your offset time is: 2026-07-26 14:30:54