C++ Tutorial 10 - Making a simple ship battle (sinking) game

  Рет қаралды 151,098

NVitanovic

NVitanovic

Күн бұрын

Пікірлер
@NVitanovic
@NVitanovic 10 жыл бұрын
I see that you are asking should you chose C++ or Java. That really depends on the thing you want to achieve. Java is cross-platform meaning, you write code once and it works on all platforms (Windows, Linux, Mac), but most of the time application will use a lot of system resources and will be slower. If you decide to write in C++ it's a lot harder to write cross-platform code because Windows, Linux and Mac are different and a lot of things are done different, that's automatically more code and harder management, but the speed is amazing. All modern games are written in C++ because it executes blazing fast. So that really depends on what you want to achieve, if you want to write something easy and want it to work on all platforms I would go for Java or C#, on the other side if you want something that will work fast, and system resources are important, you should go for C++. Hope I cleared some things for some of you! Best Regards!
@dannyblack9705
@dannyblack9705 7 жыл бұрын
Do u want to meka a toturials about Visual Basic ?
@PASBGR
@PASBGR 7 жыл бұрын
He could meka one, but Im sure its a simplified c++.
@NVitanovic
@NVitanovic 11 жыл бұрын
1) Yes I will make more tutorials. 2) I think I will start also tutorials for C# when I finish simple C++ and those tutorials will all be about GUI and using various controls.
@X3X1T0
@X3X1T0 11 жыл бұрын
Great work. I watched all your tutorials to learn about C++. Please continue!
@richardjohns4734
@richardjohns4734 11 жыл бұрын
Love all the tutorials, Can you please continue with C++ I want to get advanced in it :)
@BrandonWuPwns
@BrandonWuPwns 11 жыл бұрын
Please continue like Jose said. Great tutorials which helped me learn really basic C++. I'm a student in high school, and would like to learn C++ from you.
@jlirving
@jlirving 9 жыл бұрын
Really nice bit of code which helped me get the logic down for my own battle ship game, THANKS
@naza.02
@naza.02 2 жыл бұрын
Thank you very much, you were the only one who knew how to explain it well 10/10
@victoriasanders2299
@victoriasanders2299 11 жыл бұрын
hi there, i tried to do exactly as you have done in the tutorial. At 16:06, I started the program, right after i entered the coordinates, it gave me an error message saying "unhandled exception at 0x000B8BC5... Access violation reading location 0x333F26A0. I'm still new to programming and i did watch all your tutorials. however, i'm not sure how to continue with this error message.
@emilianot2401
@emilianot2401 2 жыл бұрын
Curious, did you find the error?
@xDxDxDMinecraft
@xDxDxDMinecraft 11 жыл бұрын
I used another function called "void Separator()". Code: for(int l = 0; l < (clms + rows); l++){ cout
@MAtukulis
@MAtukulis 8 жыл бұрын
Instead of writing void Clear(); wouldn't it be faster to write int matrix[rows][elements]={}; to set all array element to 0?
@SkiNNyPoNNy
@SkiNNyPoNNy 5 жыл бұрын
it would
@hooligangaming2193
@hooligangaming2193 10 жыл бұрын
Would love to be able to do this, watching this interested me so much
@ajulicek
@ajulicek 11 жыл бұрын
Thank you so much, you really helped me :)
@draperda95
@draperda95 10 жыл бұрын
I have to make this for a project, however slightly different...The grid (arrays) need to be shown when you compile it with all 0's being shown, however, once you guess a correct co-ordinate the co-ordinate changes from a 0 to a 1.....Any ideas how i can make this work?
@umerrathore2184
@umerrathore2184 5 жыл бұрын
Do you still have the source code of your project???
@Asterite
@Asterite 3 жыл бұрын
@@umerrathore2184 it had been 6 years bro lol how would he still have it lying around
@umerrathore2184
@umerrathore2184 3 жыл бұрын
@@Asterite xDD
@Asterite
@Asterite 3 жыл бұрын
@@umerrathore2184 me: *casually replies after a year*
@XDrSinusX
@XDrSinusX 7 жыл бұрын
Great tutorials! Thank you for doing this.
@connoredwards187
@connoredwards187 2 жыл бұрын
How do I make this so 2 players can go against eachother, choose their own ship positions and make the ships the same as the board game?
@HoudiniHarden
@HoudiniHarden 9 жыл бұрын
is it possible to make it but with user inputs for the grid size rather than hard coding it? Vectors or Dynamic Arrays maybe? Please Help!
@super4543
@super4543 6 жыл бұрын
i was talking about a game that shows a visual with spaceships around
@Rodarbal0
@Rodarbal0 9 жыл бұрын
I don't get how you get this code to compile without including the stdlib ??! can't use the rand() function without it.
@salkohajric9641
@salkohajric9641 8 жыл бұрын
Th ere are diferences betwein visual studio, code blocks and ere are diferences betwein visual studio, code blocks and dev++, probably contains of iostream lib. ++, probably contains of iostream lib, or something like that.
@xDxDxDMinecraft
@xDxDxDMinecraft 11 жыл бұрын
Might even be able to put that Separator() inside of Show() to make it work better, didn't do that, I'll look back.
@t109j
@t109j 6 жыл бұрын
I would call this game more of a minesweeper like game than a battleship game.
@darkwrath0561
@darkwrath0561 5 жыл бұрын
i dont understand why but every time i run it and it says number of ships left it gives me some strange number like 141242. i tried to fix it but all it did was make it worse. now it only displays 0
@yihsiao_47426
@yihsiao_47426 5 жыл бұрын
same here. but i think it's supposed to be 0, since the codes didn't set any value.
@vx.nocturne
@vx.nocturne 4 жыл бұрын
uhh....i tested the code but it says that there's errors and the specific function is not declared
@jesuscristo8198
@jesuscristo8198 9 жыл бұрын
something doesn't work, when i run the program the screen is all black and don't show me any thing and all the cout'' '' its on red lines :/, but i'm using code blocks, how do i fix it?
@novaaaa
@novaaaa 8 жыл бұрын
Jesus Cristo im probably a bit late, but you either need to use "using namespace std" or use "std::" in front of every cout
@yosh9w305
@yosh9w305 9 жыл бұрын
how to I use c++ on mac? And where can I download it (The c++ runner)?
@filip7627
@filip7627 9 жыл бұрын
yoshinaga hashimoto You should download visual studio
@kylemccarthy337
@kylemccarthy337 9 жыл бұрын
+yoshinaga hashimoto (YoshiKoshi) Download Codeblocks for mac
@treywaka2444
@treywaka2444 8 жыл бұрын
Xcode. It comes with a c++ compiler
@0231-g6z
@0231-g6z 8 жыл бұрын
min 11:55, Why do I get "Number of ships left is: 100". I have exactly the same code. I did everything all over and i get the same result, 100.
@0231-g6z
@0231-g6z 8 жыл бұрын
Ok.... . I finished the whole thing (with out fixing the 100 ships issue). Now the game is telling me that the number of ships left is : 00FC14EC. location changes every time I run it but its displayed under the same format. Please Help!!
@thepredatorairsoft2895
@thepredatorairsoft2895 8 жыл бұрын
this is late as fuck, i know. make sure that in your if statement has two = signs. it should be in the NumShipsLeft function.
@alexandayoung9289
@alexandayoung9289 8 жыл бұрын
yeah i keep getting 100 ships but my code is indentical to his been through video three times >
@thepredatorairsoft2895
@thepredatorairsoft2895 8 жыл бұрын
up top when you name the constant size of MAXSHIPS, change that number to whatever you want the amount of ships to be.
@alexandayoung9289
@alexandayoung9289 8 жыл бұрын
yeah mine says 10 though and it still comes up as 100 ships so confusing
@niten7147
@niten7147 5 жыл бұрын
6 years later...
@raquibshaikh4071
@raquibshaikh4071 9 жыл бұрын
hey im a beginner please tell the steps from the step selectng new project an d after i m not getting it
@stae24
@stae24 8 жыл бұрын
Look at previous tutorials
@manaskumar2544
@manaskumar2544 10 жыл бұрын
can we do this same game in c++ code ...?? . by selecting c++ at starting!!!! .?? plz do reply
@kajetanparzyszek672
@kajetanparzyszek672 10 жыл бұрын
It's in c++ :O
@wickywix9300
@wickywix9300 6 жыл бұрын
that was best tutorial thank you man !!! (Y) i learned alot
@mariahguarin5115
@mariahguarin5115 Жыл бұрын
I tried to run your program but it keeps looping
@jasonbolton2067
@jasonbolton2067 8 жыл бұрын
Thanks for the great tutorial works fine for me I just have one question concerning the while loop. "while(1)" I wasn't sure the significance of "1" as a parameter, I tried changing it to 2000000 and the game still worked normally. Remove the number entirely though, and the build breaks, I wonder what affect the number has and why it's a required parameter when it doesn't seem to matter what the value is. Regards
@templar273
@templar273 8 жыл бұрын
1 , 2000 , 1 million anything you put in the while is like TRUE the condition of the loop is always true so infinite loop 0 is FALSE
@codster2693
@codster2693 2 жыл бұрын
True=1 False=0 bro
@abdullahghani2629
@abdullahghani2629 2 жыл бұрын
How to print in the grid?
@milosstojko3311
@milosstojko3311 10 жыл бұрын
plz tell me how do i get that black gray background my head and eyes hurt from while(r u from croatia or serbia?
@grudgeswillbeheld2217
@grudgeswillbeheld2217 9 жыл бұрын
Milos Stojko I know this comment is old, but here is how you get the "Dark" background. Go to: Tools > Options. Under the "Environment" menu, click general. To the right, there will be an option that says "Color theme:" with a drop-down menu. The default option is Blue. Click it and select which one you'd like. The video uploader is using Dark.
@milosstojko3311
@milosstojko3311 9 жыл бұрын
Ty so much
@Flowbin
@Flowbin 3 жыл бұрын
@@grudgeswillbeheld2217 I know this comment is old, but i miss nice people like you on the internet
@Asterite
@Asterite 3 жыл бұрын
@@Flowbin they still exist on internet, trust me
@wyne009
@wyne009 11 жыл бұрын
i also want your Sandbox microsoft visual studio. can i have it? where it can be Download? leave a comment please! :3 tnx
@puremonk216
@puremonk216 10 жыл бұрын
He named his project sandbox...
@zal9706
@zal9706 7 жыл бұрын
This isn't much a tutorial but it's an opportunity to learn. He expects you to already know the concepts and understand what he's doing. If you don't take a while to pause and actually take in the codes logic. This is more of a learn while coding thing. Not a tutorial. The experience was valuable. But I suggest you start explaining more thoroughly if you plan to call these actual tutorials
@Ikolokos
@Ikolokos 7 жыл бұрын
Have you watched the other videos in his tutorial series (1 through 9)? He explains most of it there, and then applies it here.
@Pigeon351
@Pigeon351 7 жыл бұрын
it's only a way for people to try a bit what he talked about in his previous videos
@wickywix9300
@wickywix9300 6 жыл бұрын
yess.. correct
@ROcraftable
@ROcraftable 9 жыл бұрын
how did u make c++ black?
@neildevera9868
@neildevera9868 9 жыл бұрын
+Vlad Marius tools then options
@neildevera9868
@neildevera9868 9 жыл бұрын
+Vlad Marius lol
@giokvirkvelia2793
@giokvirkvelia2793 7 жыл бұрын
how the hell counter works?? c =0 then c++; and we got 9...
@ItsNotAllRainbows_and_Unicorns
@ItsNotAllRainbows_and_Unicorns 7 жыл бұрын
In C++ the counter starts at 0 as well as arrays. For example in MATLAB the counter and arrays start with 1. MATLAB is a scripting file and the funny thing it is created with C++. Anyway, for an explanation of why 0 is the starting point for programming languages, skillcrush.com/2013/01/17/why-programmers-start-counting-at-zero/int
@andymcdonald8922
@andymcdonald8922 3 жыл бұрын
As this was 4 years ago I'm sure you're not bothered about this anymore, but for anyone struggling with why the number of ships goes down when c++ is used, it is because it is actually the SetShips function that determines the amount of ships in the matrix. The NumberOfShips searches the array for live ship (ie 1's on the matrix) The function basically says that c starts at 0, then to search through the matrix and when it reaches a live ship (a 1) then to increment c. Therefore if it comes across 6 1's it will return c=6
@sirlagsalot64
@sirlagsalot64 4 жыл бұрын
Is this Java or HTML?
@nostradumb4ss
@nostradumb4ss 2 жыл бұрын
C++
@石名誉
@石名誉 4 жыл бұрын
Still up to date after 7 years std::cout
@swomsushi604
@swomsushi604 4 жыл бұрын
use namespace lol
@shamuhammethajyyev5828
@shamuhammethajyyev5828 4 жыл бұрын
Can somebody explain please matrix[x][y]=2??? Thanks
@andymcdonald8922
@andymcdonald8922 3 жыл бұрын
I also had this problem. I'm sure you've probably moved on from this by now, but for anybody else reading this it might help. From what can I understand a "hit" battleship turns into a 2 instead of a 1 which is a live one. This stops you guessing the same square again and again and winning the game that way. This is the way i interpreted the code: if (matrix[x][y] == 1) { //if the co ordinates from user are equal to where a 1 is then you have hit a battle ship matrix[x][y] = 2; //change the hit battleship from a 1 to a 2 return true; //returns to the caller in the main function which will print out "you got me!"
@wyne009
@wyne009 11 жыл бұрын
(y) your video shared a lots of idea :3 thank you :3 create more :3 ahhaha
@DarikAndualem
@DarikAndualem 10 ай бұрын
Bra pls another for c++ no part all part in one video
@UkiyoBappo
@UkiyoBappo Жыл бұрын
Bro music is so loud
@NishantKalra
@NishantKalra 11 жыл бұрын
i wish u titled it "minesweeper" then i would not have to waste my time ._.
@ahmed.bhewary775
@ahmed.bhewary775 5 жыл бұрын
the music, it killing the videos ... remove it
C++ Tutorial 11 - Pointers
8:26
NVitanovic
Рет қаралды 28 М.
Learning C++ by making a Game... in 1 Week?!
10:14
Floky
Рет қаралды 631 М.
How Strong Is Tape?
00:24
Stokes Twins
Рет қаралды 96 МЛН
人是不能做到吗?#火影忍者 #家人  #佐助
00:20
火影忍者一家
Рет қаралды 20 МЛН
When you have a very capricious child 😂😘👍
00:16
Like Asiya
Рет қаралды 18 МЛН
This Year in Linux, the Top Linux News of 2024
29:26
Michael Tunnell
Рет қаралды 3,1 М.
This Algorithm is 1,606,240% FASTER
13:31
ThePrimeagen
Рет қаралды 858 М.
Making My Own Programming Language and Coding a Game in It
10:19
AstroSam
Рет қаралды 1,3 МЛН
Should you learn C++?? | Prime Reacts
20:29
ThePrimeTime
Рет қаралды 412 М.
BEST WAY to make Desktop Applications in C++
26:00
The Cherno
Рет қаралды 947 М.
Новый год 2025 на ТНТ "ComedyVision!" @ComedyClubRussia
1:16:57
Python laid waste to my C++!
17:18
Sheafification of G
Рет қаралды 174 М.
C++ Tutorial 18 - Simple Snake Game (Part 1)
11:16
NVitanovic
Рет қаралды 2,2 МЛН
So you want to make a Game Engine!? (WATCH THIS before you start)
14:39
Giant Sloth Games
Рет қаралды 340 М.
Building an Enigma Machine
12:10
Code Bullet
Рет қаралды 4,3 МЛН
How Strong Is Tape?
00:24
Stokes Twins
Рет қаралды 96 МЛН