Examples of code and personal projects

Yeah nice Blackjack, looks like good progress. Also it’s cool you’re using github :slight_smile:

I agree with hh re the first program. What if your while loop began on line 13?

1 Like

Is it better now? I moved the while loop to line 14, and I deleted the else statement.

Yeah nice it’s improved. I think also you don’t need both && numberofTriesLeft>0 in the while loop and the if statement on line 16 right? As they are both doing the same thing, might be more elegant just to have one of them.

So far, I tried not use a nested if, but the program would close right away, and the last time I fixed that kind of problem, the result wasn’t the one I wanted. I think the nested if was necessary.
EDIT: I think that I’ll do a Pong clone in the holidays after christmas (I’ll have more time to spend on everything I want to do).

//Update on 26 October 2019
I have set up SDL2, and I’m going to follow tutorials about it. (I want to understand how to use SDL2 before making a pong clone)

*Double necro post.

I recently started my Source Mod; however I am confused about setting up an online repo.

https://developer.valvesoftware.com/wiki/Setting_up_an_online_repository

It says GitHub doesn’t host for free, yet I haven’t found that info anywhere else.

Can someone confirm?

That page has just a bit outdated information. Github used to charge money for private repositories, but the changed that some time ago so that you can now have private github repo for free as long as you don’t need too many team members with access to it. Public github repositories have always been free and without member limits.

1 Like
Remember my old password program? Well, I’ve translated the C++ program to C#!

Next C# program, I’ll do some dumb $hit.

1 Like

It’s a good start but you should consider trying to move to making a bit more difficult programs.

I know this is ridiculous, but I haven’t learned how to use pointers. All I know is that pointers are a data type that refers to a memory location of a variable. I don’t know how to use them, yet they are very useful in saving. How do I use them?

You are going to have a fun time with C# where everything is a reference (a fancy pointer), except when the type is a struct.
So for example if you have a function like:

public void DoSomethingWithAnObject(SomeType a){
    a.Property = 1;
}

Depending on if SomeType is a class or struct the effect is different.
Classes are always passed as reference so if you call that function with an instance of a class, the object will get modified.
But if SomeType is a struct, it is passed by value (not by reference which is a disguised pointer) , so in that case your instance that you pass to the function is not modified.

I realize I might not be the best at trying to explain this. I just wanted to highlight a difference between C++ where you explicitly know if multiple variables actually are connected to the same object (SomeType* and SomeType& versus SomeType), but in C# you just have to know if the type is a reference (class) or a value type (struct) in order to figure out if your changes to an object might interfere with other codes’ use of the same object.

1 Like
So you mean that since classes are references, I will rarely have to use pointers?

(In C# of course)

Well, explicitly you won’t. But instead you’ll always be using the equivalent of pointers.
And that makes it easy to make bugs due to random functions changing the properties of objects they shouldn’t. To fight that you need to understand the semantics of pointers (ie. multiple variables that access the same object).

1 Like

Did you do like a 1-to-1 following of the tutorial, or close to it? If you did that, then you might want to next try to add some small new features to the project you made to make sure you truly understood what the code does.

2 Likes

Update: Now, I’ll be working on my gamemode on Garry’s Mod.

1 Like
DANG IT! I’m desperately trying to set up stamina, but I just can’t! Health and Armor have their own methods for Player and Entity classes, but stamina has never been one. I tried to set up stamina methods and integrate it into the player class, but it didn’t work. What a shame! Shame on me!
I’ve spent the entire afternoon on it! Seems like I’m just complicating the task.

I’ll try out later.

Perhaps you could look at an existing gamemode that adds stamina. I’m sure I’ve seen gmod mods that add a sprinting stamina bar.

1 Like
Nevermind, it was actually more simple than I thought. I just had to use HL2’s AUX power with Player:GetSuitPower(). Only problem is that it counts also for drowning, thus I’ll have to change it later.

I have finished the barebones (like 4%) of the Formicarium Project. It has a run time of 18 seconds, the link below has the Python file and incase you don’t trust me (you shouldn’t download python files from people you don’t trust) I have all the code in ‘formicarium_project_non_pyhton.txt’ that you can read and paste into a Python Shell. I have caught some errors and I am using one to cause Python to crash as a way to quit.


This link lasts one week.

If this is against the rules, feel free to smite this post that breaks the rules off the forum.

What is this? was this discussed before?