coding

  1. D

    Automatically move threads to a different board on a forum

    Hi All, I work for a company (not disclosing which) and we have to create announcements on our forum for upcoming releases. We have to create announcements a day prior to the release on our internal board and then we move them to the product board on the day of the release. Is there a way I...
  2. Spencer W. 292

    FiveM Script Coding

    Hello! I am new to LUA Code and I am looking for a couple of fellow coders to join me in modifying a rideable animal script for FiveM. Any takers?
  3. LTomy

    Introduction to coding - 15. Conclusion

    Conclusion Improving the game There is a great amount of improvements that we could make to the game. It can however get complex pretty fast, so it is important to be comfortable with the basics of the programming language used before really getting into big projects. Learning to code in C++...
  4. LTomy

    Introduction to coding - 14. Adding shadows

    Adding shadows Lighting and shadows Simulating lighting and shadows can greatly improve the visuals of a video game. It may however get very complex. For the sake of simplicity, here, we will only handle the display of shadows (And in a simple way). Representation of colors Colors are often...
  5. LTomy

    Introduction to coding - 13. Buying and using potions

    Buying and using potions Obtaining gold Until now, there was no mean for the player to obtain gold. We will give the character a gold coin for each monster slayed. In the section of code executed when the player kills a monster, we will add the following code: // Increases the amount of gold by...
  6. LTomy

    Introduction to coding - 12. Adding a merchant and building

    Adding a merchant and building Adding the castle We will add a small castle at the bottom left of the window. We load its texture and create its sprite: sf::Texture castleTex; castleTex.loadFromFile("resources/castle.png"); sf::Sprite castle; castle.setTexture(castleTex); castle.setScale(4, 4)...
  7. LTomy

    Introduction to coding - 11. Making the monsters attack

    Making the monsters attack Storing information about the player To keep track of the health and the amount of gold and potions the player has, we define 3 variables: int playerGoldAmount = 0, playerPotionAmount = 0, playerHealthAmount = 3; How the monsters attack The monsters attack by casting...
  8. LTomy

    Introduction to coding - 10. Displaying information

    Displaying information Displaying text The class used to display text is sf::Text. sf::Text text; Similarly to how an object of type sf::Sprite needs a texture, an object of type sf::Text requires a font. A font specifies the shape of the characters (And other information) and an object of type...
  9. LTomy

    Introduction to coding - 9. Making the character attack

    Making the character attack Keeping track of whether a monster is alive or not A variable of type 'bool' can either equal 'true' or 'false'. Here, we define an array of 'bool' values indicating if a monster is dead or not: bool monstersDead[4]; In the loop where we assign the texture to the...
  10. LTomy

    Introduction to coding - 8. Adding monsters

    Adding monsters Displaying the monsters There are 3 textures for the monsters. To simulate an animation, we will alternate between them every 0.333 seconds. The textures: sf::Texture monsterTexs[3]; monsterTexs[0].loadFromFile("resources/monster1.png")...
  11. LTomy

    Introduction to coding - 7. Handling the collisions

    Handling the collisions Currently, collisions are not tested. The player can walk over the trees and stones. Let us resolve that. Testing the collision between two sprites The class sf::FloatRect is almost the same as sf::IntRect. The only difference is that its members (Representing its...
  12. LTomy

    Introduction to coding - 6. Adding the character

    Adding the character The sprite and texture The texture: sf::Texture playerTex; playerTex.loadFromFile("resources/player.png"); The sprite: sf::Sprite player; player.setTexture(playerTex); player.setPosition(400, 300); player.setScale(3, 3); Testing if a key is pressed The function...
  13. LTomy

    Introduction to coding - 5. Adding trees and stones

    Adding trees and stones Adding the trees The texture: sf::Texture treeTex; treeTex.loadFromFile("resources/tree.png"); The sprites: sf::Sprite trees[8]; trees[0].setPosition(50, 60); trees[1].setPosition(600, 150); trees[2].setPosition(630, 456); trees[3].setPosition(300, 600)...
  14. LTomy

    Introduction to coding - 4. Adding dirt

    Adding dirt Arrays When we have to create many variables of the same type, defining them individually may be inconvenient. In that case, it is better to create an array. An array is simply a group of variables which are individually accessed by their index within the array, rather than by...
  15. LTomy

    Introduction to coding - 3. Drawing into the window

    Drawing into the window Textures The class sf::Texture is used to store pictures in the memory of the graphic card, ready to be drawn. Its method loadFromFile loads the picture from the file located at the path received in argument. Note that, in C++, text is surrounded by quotes. // Defines...
  16. LTomy

    Introduction to coding - 2. Opening the window

    Opening the window The object sf::RenderWindow The following line of code defines an object of type sf::RenderWindow, which opens a window at its creation. sf::RenderWindow win(sf::VideoMode(800, 600), "Introduction to coding", sf::Style::Close); Above, we also provide arguments to the...
  17. LTomy

    Introduction to coding - 1. Introduction

    Introduction to coding About this tutorial The purpose of this tutorial is to introduce how coding works, with the C++ language here, by creating and explaining, step by step, the code of a small 2D game. In other words, the goal is to provide an overview of programming with the C++...
  18. O

    Python HELP! Collision detector - TURTLE

    Hello y'all! I'm new here, so I hope my question will be clear enough! I'm trying to create a Breakout game using Python n Turtle. I created my lists of blocks and my main block to .clone() but wenn the ball reaches the top of the game, where the blocks are, it only erases the first block...
  19. M

    Arduino Coding help

    Hi guys, I'm looking for some help. I saw this video and I have the components necessary minus a few dials. Does anyone know how I could take that MPU 6050 accelerometer input and translate it to the servos so that when the car accelerates, the servos would wobble a little mimicking a real...
  20. D

    HTML & CSS How to add a prefix to a user input on Wix

    I am creating a virtual business card where people can add their information and create a page with their social media links. I am almost done but I need help coding this: When a user goes to the update profile page they are presented with a bunch of option for example an Instagram username...
Top