Noob learns to code in 3 months
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: Noob learns to code in 3 months
Your biggest problem is having game logic and drawing code mixed together.
The best way to remedy the situation is to think of it in four steps.
Step 1) Spawn a bullet
Step 2) If a bullet is spawned, update the bullet
Step 3) If a bullet is spawned and hits the top of the screen or enemy, despawn bullet
Step 4) If a bullet is spawned, draw the bullet
Normally, you'd have the constuctor handle setting the params, like it's initial X and Y positions, but it can also be done by just setting the X and Y only when player presses the space bar. After that, if bullet has spawned, update Y with bullet velocity. Check for leaving screen or hit enemy and change has spawned to false. If still alive, draw bullet.
Here is a fork of your project with the changes I mentioned: Spaceballs repository
The best way to remedy the situation is to think of it in four steps.
Step 1) Spawn a bullet
Step 2) If a bullet is spawned, update the bullet
Step 3) If a bullet is spawned and hits the top of the screen or enemy, despawn bullet
Step 4) If a bullet is spawned, draw the bullet
Normally, you'd have the constuctor handle setting the params, like it's initial X and Y positions, but it can also be done by just setting the X and Y only when player presses the space bar. After that, if bullet has spawned, update Y with bullet velocity. Check for leaving screen or hit enemy and change has spawned to false. If still alive, draw bullet.
Here is a fork of your project with the changes I mentioned: Spaceballs repository
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com
Re: Noob learns to code in 3 months
^ urrmuhgurrd you're the best! All of that made so much sense.
Thanks!!!
Thanks!!!
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: Noob learns to code in 3 months
Glad to hear it
The bullet thing has been an issue for quite some time on the forums with some including myself. I've tried different ways of handling it. I've tried putting it in ship, but had the same outcome as you. I've tried putting it in Game which i did in the forked repo. Even going as far as putting it in a place that can be accessed by Ship and Game so that it can be spawned by ship, and updated by Game. I kind of like the third option.
The bullet thing has been an issue for quite some time on the forums with some including myself. I've tried different ways of handling it. I've tried putting it in ship, but had the same outcome as you. I've tried putting it in Game which i did in the forked repo. Even going as far as putting it in a place that can be accessed by Ship and Game so that it can be spawned by ship, and updated by Game. I kind of like the third option.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com
Re: Noob learns to code in 3 months
Alright so what did I do today.
Well I started making a shitty game of my own. Had issues, applied the fixes by albino papa.
Then I spent HOURS
1. Going through the code by albino papa and slowly understanding better logic than I was using before
2. Made it so you can fire 3 bullets even if the first one isn't off screen yet yay.
3. Sexified the code a bunch. Moved stuff around to make everything neat
for example, here's all the code for my UpdateModel
and the code for ComposeFrame
Pushed everything to github so if anyone wants to check it out they can find it here
https://github.com/Yumtard/Spaceballs
Main plan for tomorrow:
Go through all the code and make a lot of comments to make sure this new and improved logic sticks in my brain and make sure I'm understanding everything.
If I have time left I will PLAN added features with pen and paper before I start mashing buttons.
And if I have even more time left i might watch another tutorial
Edited by albinopapa to point to Yumtard's repo instead of mine, the changes he made are on his repo.
Wrapped the code in code tags[/code][/color]
Well I started making a shitty game of my own. Had issues, applied the fixes by albino papa.
Then I spent HOURS
1. Going through the code by albino papa and slowly understanding better logic than I was using before
2. Made it so you can fire 3 bullets even if the first one isn't off screen yet yay.
3. Sexified the code a bunch. Moved stuff around to make everything neat
for example, here's all the code for my UpdateModel
Code: Select all
void Game::UpdateModel()
{
ship.Update(wnd);
UpdateStars();
}
Code: Select all
void Game::ComposeFrame()
{
DrawStars();
ship.Draw(gfx);
}
https://github.com/Yumtard/Spaceballs
Main plan for tomorrow:
Go through all the code and make a lot of comments to make sure this new and improved logic sticks in my brain and make sure I'm understanding everything.
If I have time left I will PLAN added features with pen and paper before I start mashing buttons.
And if I have even more time left i might watch another tutorial
Edited by albinopapa to point to Yumtard's repo instead of mine, the changes he made are on his repo.
Wrapped the code in code tags
Code: Select all
[code]
Re: Noob learns to code in 3 months
Today I ended up commenting and looking through the code.
I made a list of stuff I will want to add to the game:
- enemy ships
- mines
- 3 lives
- stuff to pick up for extra health/lives
- obstacles
- weapon upgrades
- game over screen
- title screen
- a complete level with predetermined enemies, obstacles etc
- a shield you can pick up with a shield meter
- engine exhaust
Then I watched the tutorial for sound effects.
Added a song to play in the background of the game and spent a little too much time clicking buttons in audacity until I had a non horrible sound effect for the ships canon to add to the project.
Then I made a class for health
Tomorrow I will choose one of the things on the list and start making a plan for it. And will probably watch another tutorial
I made a list of stuff I will want to add to the game:
- enemy ships
- mines
- 3 lives
- stuff to pick up for extra health/lives
- obstacles
- weapon upgrades
- game over screen
- title screen
- a complete level with predetermined enemies, obstacles etc
- a shield you can pick up with a shield meter
- engine exhaust
Then I watched the tutorial for sound effects.
Added a song to play in the background of the game and spent a little too much time clicking buttons in audacity until I had a non horrible sound effect for the ships canon to add to the project.
Then I made a class for health
Code: Select all
#include "Health.h"
void Health::Damage(int dmg)
{
healthAmount -= dmg;
ColorMeter();
}
void Health::Restore(int restore)
{
healthAmount += restore;
if (healthAmount > maxHealth)
{
healthAmount = maxHealth;
}
ColorMeter();
}
void Health::Draw(Graphics& gfx)
{
gfx.DrawSquare(x, y, healthAmount, height, c);
}
bool Health::HasHealth()
{
return
healthAmount > 0;
}
void Health::ColorMeter()
{
if (healthAmount <= 100)
{
c = Colors::Red;
}
else if (healthAmount <= 200)
{
c = Colors::Yellow;
}
else
{
c = Colors::Green;
}
}
Last edited by Yumtard on January 29th, 2017, 5:24 pm, edited 1 time in total.
Re: Noob learns to code in 3 months
Damn Yumtard, you're tearing into this. I'm havin' trouble keeping up with your blog posts Keep up the good work!
Let me at least answer your direct questions to me
SFML on the other hand is made for making simple games. It's a comparatively simple framework, but it still has much more features than the Chili framework. When you go to make your portfolio pieces, you'll want to focus on making the game engine, and not on developing low-level graphics routines etc. So that is why I am going to steer you towards SFML when the time is ripe. At your pace, I might want to get you started in it in maybe 2 weeks or less.
Now I gotta check out some of your GitHub projects. Next update video looks like I'm have good material for the show-and-tell segment
Let me at least answer your direct questions to me
SFML is a framework, like the Chili framework, but it has many more features. The Chili framework is purposely feature-poor, because the idea of this series is to learn how to do all this graphics stuff and all the underlying theory and concepts yourself. The Chili framework is made for learning.Yumtard wrote: Awesome! What is SFML and why is it better for portfolio pieces?
SFML on the other hand is made for making simple games. It's a comparatively simple framework, but it still has much more features than the Chili framework. When you go to make your portfolio pieces, you'll want to focus on making the game engine, and not on developing low-level graphics routines etc. So that is why I am going to steer you towards SFML when the time is ripe. At your pace, I might want to get you started in it in maybe 2 weeks or less.
It can't hurt. Just be aware that the old stuff isn't as polished as the new stuff. There is a sticky post at the top of the forum which gives info on each tutorial from the old series. Use that to figure out what videos to watch from the old beginner and intermediate, and which ones you can skip.Yumtard wrote: Would you recommend after I've gone throught the beginners series to maybe go through the old beginners series and the intermediate series?
Now I gotta check out some of your GitHub projects. Next update video looks like I'm have good material for the show-and-tell segment
Chili
Re: Noob learns to code in 3 months
The general idea is you work in a development branch (also called a feature branch) committing and perfecting it, and then when you got i all working the way you want, you MERGE into the master.Yumtard wrote: 2. watched the tutorial on github. Understood the gist of it but will
take some practice getting used to for sure. A couple things were
unclear to me.
If I make a branch and work in it until that branch is better than
the master branch, do I now somehow promote my new branch to master?
can I make tons of branches which are all different games starting
from an empty chili framework and branch out into a bunch of games
from that one?
Here's some more info on the workflow:
https://www.atlassian.com/git/tutorials ... h-workflow
There are many workflows that can be/are used with git. As a beginner just experiment and don't worry too much about whether you're "doing it right". A sub-optimal use of source control is still 100x better than using no source control at all.
Chili
Re: Noob learns to code in 3 months
Thanks Chili I'm doing my best for surechili wrote:Damn Yumtard, you're tearing into this. I'm havin' trouble keeping up with your blog posts Keep up the good work!
Let me at least answer your direct questions to me
SFML is a framework, like the Chili framework, but it has many more features. The Chili framework is purposely feature-poor, because the idea of this series is to learn how to do all this graphics stuff and all the underlying theory and concepts yourself. The Chili framework is made for learning.Yumtard wrote: Awesome! What is SFML and why is it better for portfolio pieces?
SFML on the other hand is made for making simple games. It's a comparatively simple framework, but it still has much more features than the Chili framework. When you go to make your portfolio pieces, you'll want to focus on making the game engine, and not on developing low-level graphics routines etc. So that is why I am going to steer you towards SFML when the time is ripe. At your pace, I might want to get you started in it in maybe 2 weeks or less.
It can't hurt. Just be aware that the old stuff isn't as polished as the new stuff. There is a sticky post at the top of the forum which gives info on each tutorial from the old series. Use that to figure out what videos to watch from the old beginner and intermediate, and which ones you can skip.Yumtard wrote: Would you recommend after I've gone throught the beginners series to maybe go through the old beginners series and the intermediate series?
Now I gotta check out some of your GitHub projects. Next update video looks like I'm have good material for the show-and-tell segment
Looking forward to show and tell
Re: Noob learns to code in 3 months
Alrighty! So what did I do today to improve.
Well first of all I had a math assignment to deal with. I've started a couple math courses to increase my credit a bit and slightly increase chances of getting accepted to programming school.
It's just 8-10 programming students per year getting accepted to that school so gotta do everything I can.
So, math assignment took a lot of time away from programming but still had time to do some coding.
I added a Mine class and a MineManager, some horrific "animation" and sound effects when the ship collides with the mines. The ships health also decreases. It took a bunch of work and flexing the dome.
So finally my game is starting to look like an actual game! A shitty game but a game none the less.
If you want to check out the code or try playing it:
https://github.com/Yumtard/Spaceballs
The song I'm using is made by a friend of mine
haven't had time to check out episode 17 yet but will give it a go now before I fall asleep
Well first of all I had a math assignment to deal with. I've started a couple math courses to increase my credit a bit and slightly increase chances of getting accepted to programming school.
It's just 8-10 programming students per year getting accepted to that school so gotta do everything I can.
So, math assignment took a lot of time away from programming but still had time to do some coding.
I added a Mine class and a MineManager, some horrific "animation" and sound effects when the ship collides with the mines. The ships health also decreases. It took a bunch of work and flexing the dome.
So finally my game is starting to look like an actual game! A shitty game but a game none the less.
If you want to check out the code or try playing it:
https://github.com/Yumtard/Spaceballs
The song I'm using is made by a friend of mine
haven't had time to check out episode 17 yet but will give it a go now before I fall asleep
Ah! That makes a ton of sense. Liking git more and morechili wrote:The general idea is you work in a development branch (also called a feature branch) committing and perfecting it, and then when you got i all working the way you want, you MERGE into the master.Yumtard wrote: 2. watched the tutorial on github. Understood the gist of it but will
take some practice getting used to for sure. A couple things were
unclear to me.
If I make a branch and work in it until that branch is better than
the master branch, do I now somehow promote my new branch to master?
can I make tons of branches which are all different games starting
from an empty chili framework and branch out into a bunch of games
from that one?
Here's some more info on the workflow:
https://www.atlassian.com/git/tutorials ... h-workflow
There are many workflows that can be/are used with git. As a beginner just experiment and don't worry too much about whether you're "doing it right". A sub-optimal use of source control is still 100x better than using no source control at all.
Re: Noob learns to code in 3 months
Question for chili.
Right now the mines are just appearing at top of the screen. Would prefer to have them "glide" in gradually, but I can't start drawing them off screen. Is this something that can't be done with putpixel? I know you mentioned, in one of your episodes, something about an upcoming tutorial about a better way to implement graphics. Any idea which episode that will be?
No rush ofc just excited
Right now the mines are just appearing at top of the screen. Would prefer to have them "glide" in gradually, but I can't start drawing them off screen. Is this something that can't be done with putpixel? I know you mentioned, in one of your episodes, something about an upcoming tutorial about a better way to implement graphics. Any idea which episode that will be?
No rush ofc just excited