Answered need help with a windows forms app game

rowlandsfc

Active member
Joined
Feb 3, 2019
Messages
43
Location
bridgend
Programming Experience
Beginner
so i created a basic game and it has a level that is basically space invaders. i have a class for the bad guys, and a class for the bullets, but sometimes i have an issue in game where the bullet just goes straight through the enemy rather than actually hitting it. this doesnt happen all the time so i know the the bullet class and the contact between bullet and enemy does work bu t just dont understand why sometimes it would go straight through?


bullet collision with enemy:
bullet.RemoveAll(bullets => bullets.isDisposed); // check for collicion between enemies and bullets
            foreach(JetBullet b in bullet)
            {
                b.MoveBullet(this.panel1);
                foreach(EnemyShips enemy in enemies)
                {
                    if (b.d.Bounds.IntersectsWith(enemy.e.Bounds))
                    {
                        b.isDisposed = true;
                        b.d.Dispose();
                        enemy.isDisposed = true;
                        enemy.e.Dispose();
                        enemyNumber--;
                        enemyTimer.Enabled = true;
                        score = score + 5;
                        enemiesKilled = enemiesKilled + 1;
                        lblKilled.Text = "Enemies Kileed: " + enemiesKilled;
                        lblScore.Text = "Score: " + score;
                        enemiesKilled = enemiesKilled + 1;
                    }
                }
            }

thats the code i have for the collision between the 2 objects
 
Wow. Your tutors need tutoring or replacing. And their study material needs burning. If they were modern-day tutors, they'd have you learning WPF. Teaching you Winforms first is doing you a disadvantage, because there is a huge difference between WPF/Winforms, and transitioning from Winforms to WPF has a huge learning experience. Frankly, I don't see the point why they are teaching you an EOL product.

Obviously you should do as they ask for the sake of any exams you may have to undergo, but If I were you, I'd do your own research on what they are telling and teaching you, so you can find corrections to what they are teaching you. Anyone who tries to justify using 400 objects on a form is not a tutor but a clown. That's just absurd.

You can always ask us here about your studies if you have any doubts about how they are teaching you, or what they are trying to tell you. I can't even imagine what 400 labels on a form would look like.
 
Wow. Your tutors need tutoring or replacing. And their study material needs burning. If they were modern-day tutors, they'd have you learning WPF. Teaching you Winforms first is doing you a disadvantage, because there is a huge difference between WPF/Winforms, and transitioning from Winforms to WPF has a huge learning experience. Frankly, I don't see the point why they are teaching you an EOL product.

Obviously you should do as they ask for the sake of any exams you may have to undergo, but If I were you, I'd do your own research on what they are telling and teaching you, so you can find corrections to what they are teaching you. Anyone who tries to justify using 400 objects on a form is not a tutor but a clown. That's just absurd.

You can always ask us here about your studies if you have any doubts about how they are teaching you, or what they are trying to tell you. I can't even imagine what 400 labels on a form would look like.
I'm gonna have to look into learning wpf on my own then, I have the option of a year in uni after this college course aswell so id like to learn more anywya, is there anywhere that is good for wp tutorials etc?
 
There is Welcome - The complete WPF tutorial

A quick search on any search engine will return results of numerous places to learn. You are also in the right place by using these forums. You are welcome to ask as many questions as you like on these forums whenever you get stuck.
so ive got rid of all the labels and set up both my the players character and the mines as classes and got the player movement working at the collision detection between player and mines working, bow i need to figured how how i detect those mines that are around the player and display the amount,any suggestions where i could start with this?
 
If can detect collision between the player and a mine, then you can detect potential collisions between the player and a mine following a what-if scenario of the player stepping in that direction.
 
If can detect collision between the player and a mine, then you can detect potential collisions between the player and a mine following a what-if scenario of the player stepping in that direction.
i understand what you are saying but im not sure how to make an if statement for him to move without making him actually move?
 
To determine if you have a collision, you test if the player is at a particular position, and check what else is in that position. The position is not the player. Good object oriented design recommends "loose coupling-tight cohesion". If your player is tightly coupled to the position, then you just discovered why that adage exists.
 

Latest posts

Back
Top Bottom