Official CS50x Thread (Free Online Harvard Programming [C, PHP, HTML, Javascript, SQL...] Courses

Data-Hawk

I have no strings on me.
Joined
May 6, 2012
Messages
8,420
Reputation
1,985
Daps
16,306
Reppin
Oasis
First off, good luck to everyone that's embarking on this journey. Hopefully you are all able to develop some new useful skills on this quest.

Now, my advice in here for the people that are learning to code is to LEARN TO LOVE IT. If you are only thinking about the money, programming will eat your ass alive. Why must you learn to love it? Technology changes A LOT. What you learn today can become obsolete next year. You have to constantly read and practice to get better. You have to CONSTANTLY learn new shyt. You can never learn enough and be cool with just that knowledge. Only if you love it will you be able to get better to the point where you can actually write or contribute to useful applications that use multiple technologies.

I'm not trying to deter anyone...just letting you know the real. Learn to love it, practice everyday, read, watch videos, and hopefully you'll be the one inventing some new, in-demand technology.

Good luck ya'll :salute:

Yeah, let me add onto that because I think some people are trying to turn the IT game into the Real estate game where they think they are going to hop into it and become paid or after watching how Facebook/Instragram blew up they have some great 'idea". A lot of people don't know but Zuckerberg was coding up to 16hrs a day , it got to the point where dude almost passed out because he was working so hard. So ideas are just that, an idea. Its the implementation that counts. So not to discourage anybody or hate, but just being real. If you don't love coding do yourself the favor and stay away, I've been coding since I was 15 ( 32 now ) and want to cry when I have to work on something at work that I'm really not that interested in. Best examples of people who love to code are Markus persson( Minecraft creator) and John Carmack( Doom Quake etc), both you can follow on twitter. Both are millionaires and they still code everyday when they could be chilling on a beach or travel for the rest of their lives, heck even Mark Zuckerburg was still writing code up til 2008 when he was already beyond rich. All three are extremes, but I'm sure a lot of new people are jumping into this because of the whole Social network craze or hearing about the people who became millionaires from releasing a mobile app. Heck even me after all these years I'm still trying to match their work ethic, but sometimes it can be discouraging when you spend anywhere from hrs to days chasing down a stupid bug and while its one simple bug, it really fukkks up your app..lol

I actually keep this screenshot in my phone for days I get Frustrated, a lot of programmers considered John Carmack to be one of the best programmers to ever touch a keyboard and even he has days like this:

2cek7pt.png


So for all the new comers, be prepared to be frustrated and feel dumb as hell. But if you really love it, you can't imagine yourself doing anything else.
 

Data-Hawk

I have no strings on me.
Joined
May 6, 2012
Messages
8,420
Reputation
1,985
Daps
16,306
Reppin
Oasis

for your second bug( take into account I don't really know the scratch language )

2. When a Ghoul reaches the bottom, most of the time, it re-spawns in the middle of the screen to glide to the bottom again to finally subtract 10 points. The 10 points should be subtracted on the first time and the Ghoul should not re-spawn.

Here's how I would try to solve it:

Get the screen display size aka the window size. Lets say the height of the window is 480
Get the texture width/height of the Ghoul ( usually 16x16 or 32x32 )

As the Ghoul travels in the Y direction( Downward ), you'll know its off screen, if you check it's coordinates and the Y coordinates is greater than the window height + Ghoul height ( Note some game frameworks treat screen coordinates differently, going downward maybe going in the negative direction or positive direction ). But lets say the top of the screen is 0 and the bottom is 480. You'll know the ghoul is off-screen when it's y coordinate is 480 + 32 = 512

If Ghoul Coordinates > 480 + 32
subtract 10 from PlayerScore.
Destroy object
End



Edit. If Ghoul Y Position = -205 ( instead of -180, remember you have to factor in the Ghouls height )...give that a try, this should ensure he spawns off screen.

Also I would change the initial position of the Ghoul from 180 to 205
 
Last edited:

Data-Hawk

I have no strings on me.
Joined
May 6, 2012
Messages
8,420
Reputation
1,985
Daps
16,306
Reppin
Oasis
Ahh still not subtracting the points... is this the language they are using during the course? scratch?
 

Liu Kang

KING KILLAYAN MBRRRAPPÉ
Supporter
Joined
May 3, 2012
Messages
13,749
Reputation
5,513
Daps
29,903
game is cheating :beli:
No it's not. You just mad you can't beat it :umad:








I can't either :sadcam:








Finally did, after slowing down the Ghouls :whew:
The thing is to shoot the Ghouls ASAP when there is no visible stars or when you caught a star but to wait AMAP to shoot the Ghouls in order to let the star glide and avoid a too far Ghoul respawn.
And yes, it's buggy but I can't solve it : when a Ghoul passes the Spaceship, it should only subtract 10 points and respawns on top, but most of the time, it respawns randomly on the screen (without subtracting 10 points) and sometimes just around the Spaceship which causes a unexpected Game Over because the Ghouls is too close and crashes into the Spaceship :sadcam:

The bug doesn't exist if the Ghoul passes you in the beginning or it if a Ghoul passes you a consecutively after a first time and so on. But if it wrongly passes you twice and you shoot a Ghoul after, the bug resets and next time a Ghoul passes you, it will respawn randomly...
:ohlawd: man i knew u would come through with some piff , am watching that intro to sratch vid tomorrow and start working on my game , my shyt finna be :flabbynsick: though , i was going through your script and it seemed pretty simple, any tips for me?
Less is more obviously, so the the cleaner and simpler the code, the easier it is to fix it :
- When you see a recurring code, make it a function (with "add blocs" on Scratch)
- Name functions, variables as clearer as possible (ie, don't name a function "function01" but make the name a description ie "spaceship_movement")
- Don't use "spaces", use "underscores" to represent them
- Code in lowercase, sometimes coding is case sensitive and a little detail can fukk up a whole script

You'll learn in a few lessons that variables should be declared beforehand or before any script so take that habit : set the things then showed them or start them not otherwise.

For the conditions, what I did was state the exceptions before the rule but I don't know if it's the normal thing to do :
- If "problem 1" then "solution 1"
Else If "problem 2" then "solution 2"
Else If "problem 3" then "solution 3"
Else "normal"

Also don't hesitate to sketch or write down your ideas. Coding is logical, so make diagrams to represent your scripts (flowcharts for conditions for example) so you can spot any possible bugs or illogical stuff.

But that's how I do, maybe @Ctrl, @FreshFromATL or @Data-Hawk will tell you otherwise because I only learnt coding by myself.

You can also proceed by steps ie :
- Step 1 : My title screen then the rules, so everything but the stage is hidden, I made the music started on the rule screen and put a little tick so I would be sure people fully read the rules
- Step 2 : The splash screen, I show the level and the score variables and put a button for the player to start the game whenever he wants.
- Step 3 : The game starts with its rules, so I show all the sprites with the inherent normal scripts : the stars and the ghouls glides down at different speeds and when they reach the bottom, they respawns randomly on top of the screen to glide down again. The spaceship is a the bottom, moves from left to right and shoot lasers. The lasers move following a vertical direction and do so at a steady speed.
- Step 4 : The exceptions
--- 4a : What do I do if the star : 1. meet the spaceship ? It gives a speed boost. 2. is touched by a laser ? It disappears and respawn after some time. 3. reach the bottom ? it gets back on top, wait a little, then glide again
--- 4b : What do I do if the ghoul : 1. meet the spaceship ? It blows it up. 2. is touched by a laser ? It disappears, gives the player 1 point, then glides again. 3. reach the bottom ? it makes the player lose 10 points, then glide again immediately
--- 4c : What do I do the bring some challenge ? 1. Every 10 points, the player passes a new level till level 6. 2. Every new level increases the speed of the ghoul (variable here).
- Step 5 : How does the game end (you don't want a game which lasts forever) ?
--- Win if the player reach 60 points -> Victory screen
--- Lose if the player is touched by a Ghoul -> Game over screen
--- Lose if the player's score is below 0 -> Game over screen

And don't forget to implement sounds, it's better with them :lolbron:
Ahh still not subtracting the points... is this the language they are using during the course? scratch?
Scratch is only a way to introduce the concepts of "variable", "conditions", "functions", "scripts" on so on... I know already about that because I have basic knowledge of PHP but it still a great way to learn about that. Then with the incoming lessons, we will get into some proper languages.
And yeah, I spent a good amount of time on those two bugs and decided to surrender after a while because I was not going anywhere.
 

Kodie

Pro
Joined
May 1, 2012
Messages
1,810
Reputation
100
Daps
1,525
Damn yall already doing some impressive stuff in here. Love this movement :salute:
 

Data-Hawk

I have no strings on me.
Joined
May 6, 2012
Messages
8,420
Reputation
1,985
Daps
16,306
Reppin
Oasis
Week 1 already introduces C and Linux commands.
*fastens seatbelt* :merchant:
Straight C is pretty simple. It only becomes a pain when dealing with large projects or the fact you to have manually manage memory( source of alot of security problems ). for basic program its nit much harder than the scratch language.
 

Ohene

Free Sheist
Joined
May 1, 2012
Messages
74,100
Reputation
6,416
Daps
127,697
Reppin
Toronto
If there's anyone here that's serious about learning to code and ever needs some help with something they're learning feel free to hit me up. I program for a living and I've taught others professionally and am happy to help people learn how to program.
:bow:
 

Liu Kang

KING KILLAYAN MBRRRAPPÉ
Supporter
Joined
May 3, 2012
Messages
13,749
Reputation
5,513
Daps
29,903
Straight C is pretty simple. It only becomes a pain when dealing with large projects or the fact you to have manually manage memory( source of alot of security problems ). for basic program its nit much harder than the scratch language.
So you know C then, what are its use mainly ? Windows programs or wider stuff like Android apps ?
What's the difference with C++ or C# ?
More important, is it worth it to learn it now ? Does it have a future or will it be outdated soon ?

FYI, I'm not into this stuff to make money but just to learn. From what I saw the course will also take on PHP (and Mysql I hope) and that's what I want because I need it to manage some sites I built, more efficiently. It's only for so much that HTML alone can pretend unfortunately :ld:
But if I can learn to build android apps, well, that will be another string to my bow. And I don't think I will be able to do so only with that course obviously but with a solid basis, one can build a good efficiently.
 
Top