# Visual Basic > Games and Graphics Programming > Game Demos >  VB: 2D Counter Strike [Source]

## alexDrewn

this is an alpha version of a game im working on.  

Its a 2d version of counter strike.

I've been working on it for the last 4 months and this is all I've gotten done so far.  I still need to fix wall collision,add bullet collsion, weapons, a score menu, and a buy menu.

It is important to run the game at 1024x768.

please leave comments.


How to host a game:
1.Click host
2.choose a team
3.Press escape and give the IP address that is in the IP address box to other players 

How to connect to a game:
1.enter the server IP in the IP address box.
2.click add IP
3.click connect
4.choose a team


Controls:

W,A,S,D and SPACE

*UPDATE 10/3/04*
I've zipped the code, exe, and map editor together.
No game updates though.
Map editor located in the maps folder.

*UPDATE 7/8/05*
Check out www.cs2d.com for a really good 2d 
counter-strike game.
Look for a demo of a new game Im working on soon.

----------


## BodwadUK

After an incident that i wasnt around to witness nobody runs exe's anymore. people have a tendancy to be evil and write programs to destroy other peoples pc's. 

 :Smilie:

----------


## jonask

Yes, I totaly agree with BodwadUK. It's not smart to just post an exe file, people can't be to safe these days  :Wink:  and besides, if you don't post your code, how are we supposed to learn anything from your writing, or help you out with your code. Post the code too, so people can se what you've written =)

Cheers

----------


## BodwadUK

I ran it and it seems ok  :Smilie:

----------


## Electroman

> _Posted by BodwadUK_ 
> *I ran it and it seems ok *


  :Roll Eyes (Sarcastic):  

Well I suppose I will run it now  :Wink: .

----------


## Electroman

Nice :Smilie: , mind I didn't have anyone to play with  :Frown: .

BTW you're not clipping the tiles at the edge. And also you not clearing the back buffer I can see (this isn't a problem but that how I could tell you weren't clipping the edges  :Wink:  )

----------


## Merri

Add Esc support to credits. Please.

----------


## NoteMe

The sprite for the guy is not changing when you are running uppvards and shoot like in the other directions...

----------


## alexDrewn

Electroman , did you run the game at 1042x768?
if you have higher res, then you might see the back buffer around the edges.

Good idea merri, thanks.

The sprite might not be changing frames right because i didnt make the animation time based.

----------


## Electroman

> _Posted by alexDrewn_ 
> *Electroman , did you run the game at 1042x768?*


 There was an option  :Confused:  My desktop id at 1280x1024 I suppose that could be it, mind I advise you do it properly and clip the edges, means you don't nne to do as much painting too  :Wink:

----------


## NoteMe

> _Originally posted by alexDrewn_ 
> *
> The sprite might not be changing frames right because i didnt make the animation time based.*


What I ment was that if you hold the shooting button down when you are moving in a direction, h puts the gun to his sholder and shoot, that does not happen if he run upwards... :Wink:

----------


## alexDrewn

What do you mean clip the edges? Do you mean I shouldnt draw the tiles that arent going to be seen?

Yea I didnt feel like adding a shoot upward animation.  The art is done, unless i pay someone to draw some really good sprites for me.

Has anyone played with other people yet?

If you run the game at 1024x768 the frame rate will dramatically drop.


Heres the code, theres a map editor in the maps folder:

----------


## Electroman

> _Posted by alexDrewn_ 
> *What do you mean clip the edges? Do you mean I shouldnt draw the tiles that arent going to be seen?*


 I mean the Tiles are part on and part off the edges will not get drawn because in the Blt routine if the operation your doing doesn't fit on the surface it just ignore the whole operation and doesn't draw any of the tiles.
So what you do is alter the DestRECT to make sure its not going off the surface, then you alter the SrcRECT to select just the portion of the image that goes into the size of the DestRECT you now have.

Did that make sense? I know I probably didn't word it the best I could do but I didn't know how much detail I should go into cos I don't know how much you know  :Wink: .






> _Posted by alexDrewn_ 
> *Has anyone played with other people yet?
> 
> If you run the game at 1024x768 the frame rate will dramatically drop.*


 Are you saying even though i'm running it at a higher res now that if I put the res down to 1024x768 then it'll run slower? It actually runs at a good speed how it is anyway  :Wink: .

----------


## alexDrewn

Sorry I still dont understand.  I draw only part of the tiles that line the top and left side of the screen.  If you run at a higer res than 1024x768, youll see that the very top and very left tiles are only a fraction of a full tile.  And that the right and bottom tiles are full times.  

But the game is messed up at a higer res than 1024x768, because the game doesnt fill the whole screen.



I meant to say any higher than 1024x768 will have  bad frame rates, at least when playing with someone else for some reason.

----------


## Electroman

Ow, what post does it use BTW for the multi player? just becuase I would need to allow my Firewall to unblock it if I played it online.

----------


## alexDrewn

Do you mean port?

It uses port 7118 if that port isnt being used.  If it is being used it will try the next port and so on until it finds a unused port.

The game only works through LANS

----------


## Electroman

Yeah I meant port, dunno what I was thinking. Only works on LANs  :Sick:  how come  :Frown: , I only have the one monitor so that wouldn't really work for me  :Frown: .

----------


## alexDrewn

i dont know how to make it work through the internet.

or maybe you can make it work throught the net.

Could I play with someone over the net if I know only their IP?

Electroman?

----------


## alkatran

If you know their IP and they know you want to connect, then yes, you can play through the net. The basic idea is:

-Person 1 tells port X to listen
-Person 2 sends connect request to person 1's ip on port X
-Person 1 receives request and accepts (or denies) the connection
-Person 2 receives confirmation of acceptance and the connection is officialy established

----------


## BodwadUK

AKA its the same as a LAN  :Big Grin:

----------


## Tekken

I'd love to try the game, but a little problem... It won't run, When I try to open the file i get




> Compontent 'MSWINSCK.OCX' or one of its dependencies not correctly registered: a file is missing or invalid


What os are you using? I'm on XP and no really wierd programs installed so its not likely to be software conflict.

Possibly this just won't run on XP (High Technology my ( | ) )

----------


## alkatran

That's a standard error.. you don't have the winsock .OCX

Search for that file on the internet, it's not very hard to find.

----------


## Electroman

> _Posted by Tekken_ 
> *I'd love to try the game, but a little problem... It won't run, When I try to open the file i get
> 
> 
> 
> What os are you using? I'm on XP and no really wierd programs installed so its not likely to be software conflict.
> 
> Possibly this just won't run on XP (High Technology my ( | ) )*


 You do have the VB IDE installed on that PC? The ocx file would have came with it  :Wink: .

----------


## BodwadUK

Or install the vb6 runtimes from microsoft. I am sure they said the OS came with them as standard but there we go  :Big Grin:

----------


## d3graph

good work


i got a bug

when we fire gunshot remain on screen

see attched image

----------


## alexDrewn

Thanks D3,
            Thats just a muzzle flash though.  I never got around to adding bullets yet.

I havent worked on this game for a long time im really busy with school.  Digipen is really tough this year.

Im thinking about porting the game over to c++ and using D3D.

I've attached my lastest build.  If you have winsock errors, run the winsock program that I have included.  DO NOT RUN the winsock program if you have no errors.

Collision is also really F'd up.

The most people I've had connected was 4,  and it only lastest about 8 minutes before the game crashed.  But it was awesome while it lastest.  Even thougt all we did was run around.

----------


## RickP

Very impressive.  I once had this idea as I love counter-strike. It looks like you draw the gun seperate from the player, is that true? It would almost have to in CS. Also are you using DX? It seems not with all the windows controls you show. If you aren't you most likely show as that would run faster. The dust layout isn't there. Seems maps will be limited due to the fact that multiple levels would be hard to pull off, though not impossible. I think this is one of the reasons I didn't follow through. 

Where did you get that sprite of the CT? I like it. I might pick up on making a version of this game still.

----------


## toughcoder

Hello alexDrewn,
Excellent work buddy. :Thumb:  
I was able to play the game on LAN with 3 guyz, was gud but crashed after some time. Have some suggestions.
*
1. The game doesnt displays the whole map. On my sys. on 1024x768 resolution, only half the screen contained the map, the other half was blank. When i moved onto my right, then the map was displayed on the right.

2. Also, its not catching diagonal keys like DOWN+RIGHT keys. U can do that pretty easily so that the character moves diagonally.

3. Also, on my sys. with a RADEON SAPPHIRE 9800 PRO, the frame rates were pretty dismal. U can do better than that.

4. And last, chk why the hell is it crashing. Mayb some overflow or memory leak.* 

Overall, a good attempt. 3 cheers & 4 stars (****)  :Alien Frog:

----------


## alexDrewn

Dont know why only part of the screen appeared at first.

I dropped frame rates on purpose.  It's a temp fix to limit how many frames are being sent to the server or clients.

----------


## Girvo911

Hey, nice game. It runs well on my cmouter, but the screen problem is there for me as well. It doesnt display the whole map, until i walk into the other side. its weird. aside from that, good game. Keep at it.

----------


## emanz

i cant play it coz the load_winsock file doesnt work????
it keeps on saying 
"runtime error '76'
path not found
wat do i do now????

----------


## emanz

i downloaded the winsck.ocx file but it keeps saying the same thing that the file is missing????????
wat up wit dat?????

----------


## Nove

Did you put in your system/system32 folder?

----------


## emanz

then wat do i do afta dat?

----------


## emanz

hey nove u ran the game yet???

----------


## Nove

No, I haven't looked into it.  Are you sure you downloaded the right .ocx and that it's in the correct folder?  If you have and it still isn't working, you may need to register the control.  I forgot the program for this but I can look it up if you need it.

----------


## BodwadUK

Command prompt

regsvr32 "winsock.ocx"

 :Smilie:

----------


## Y Anderson

damn i smell some major profit from a phone game, but i suggest chaning it to not include the words "counter strike" else sierra might bring down some sort of law suit

----------


## Nove

Cell phones run VB applications now?

----------


## BodwadUK

What have you all been smoking?   :Sick:   :Confused:

----------


## chemicalNova

> Cell phones run VB applications now?


No, but PDA's do. :P

chem

----------


## asgsoft

you can add a built in screen resilon setter?

----------


## Nove

I thought PDA's had their own operating system, how would that run a Windows application?

----------


## BodwadUK

You can but it needs a slight change to your methods   :Smilie:

----------


## feneck

(very nice app/game ^.^)

The only code I know of that runs on phones is Java :S and i hate java lol... so sluggish and old... yet people seem to use it :S

----------


## psychotomus

I use to have a PDA and it ran my vb6 programs. i needed a vb6 add-in though.

----------


## Hlinzi

Nice!

----------


## ohailo

DAMN...why if we go to lan games then connected each other...we cant be enemies....we cant shot and die...sorry for bad english...can anyone help this?

----------

