That's the first time I ever pulled the WinForms c# project template to check code. Kinda' neat. so, thank you for that. Might play with that one day.
4 minutes ago, phil67rpg said:I am getting better at c#
hehe...yeah me too.
That's the first time I ever pulled the WinForms c# project template to check code. Kinda' neat. so, thank you for that. Might play with that one day.
4 minutes ago, phil67rpg said:I am getting better at c#
hehe...yeah me too.
Dev careful. Pixel on board.
Buckle up. Everything will be revealed.
I found out how to initialize an list.
IList<Bug> bugs = new List<Bug>() {
new Bug() { px=120, py=0 },
new Bug() { px=180, py=0 },
new Bug() { px=240, py=0 },
new Bug() { px=300, py=0 },
new Bug() { px=360, py=0 },
new Bug() { px=420, py=0 },
new Bug() { px=480, py=0 },
new Bug() { px=540, py=0 },
new Bug() { px=600, py=0 },};
Huh, well that's weird. Looks like it is better with as the interface.
https://stackoverflow.com/questions/400135/listt-or-ilistt
nice one.
Dev careful. Pixel on board.
Buckle up. Everything will be revealed.
I am going to use this list because it seems to work for me, I found it on the web. next I am going to implement the loops for drawing.
well I have implemented the loop when the bullet hits the bug, all the bugs draw a collision image.
public class Bug
{
public int px;
public int py;
public bool drawflag = true;
public bool collision = false;
public int killtimer = 0;
};
IList<Bug> bugs = new List<Bug>() {
new Bug() { px=120, py=0 },
new Bug() { px=180, py=0 },
new Bug() { px=240, py=0 },
new Bug() { px=300, py=0 },
new Bug() { px=360, py=0 },
new Bug() { px=420, py=0 },
new Bug() { px=480, py=0 },
new Bug() { px=540, py=0 },
new Bug() { px=600, py=0 },};
public void Form1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.DrawImage(ship, 350 + x, 530);
e.Graphics.DrawImage(bullet, 375 + x, 520 + y);
foreach(Bug bug in bugs)
{
if(bug.drawflag==true)
{
if (y <= -510 && x >= -15 && x <= 15)
{
bug.collision = true;
}
}
if (bug.collision==true)
{
e.Graphics.DrawImage(coll, bug.px, bug.py);
}
else if(bug.drawflag==true)
{
e.Graphics.DrawImage(bug_one, bug.px, bug.py);
}
}
if (y <= -510 && x >= -75 && x <= -45)
{
}
}
public void timer1_Tick(object sender, EventArgs e)
{
y -= 5;
Invalidate();
}
where's your reset for the bullet...that was on your original pseudo code.
Go back to my pseudo code. I've marked a section with # symbols a couple days ago. Nice to have gotten here already. There are a few things you need to set when collision occurs to make this happen proper.
good times...
Dev careful. Pixel on board.
Buckle up. Everything will be revealed.
14 hours ago, GoliathForge said:where's your reset for the bullet...that was on your original pseudo code.
![]()
Go back to my pseudo code. I've marked a section with # symbols a couple days ago. Nice to have gotten here already. There are a few things you need to set when collision occurs to make this happen proper.
good times...
what do I have to do to get my collision to work correctly.
What is not working correctly? What have you tried? Is this a programming question or a design question? Can you provide a description of what would be correct behavior? Are you still satisfied with our conversations? I think the pseudo code was good. I can see your current hurdle as perhaps during collection iteration and this concept of variable object and maybe a little of member ownership and. In my eyes the hard part is over. You have a class object of your own making now. Hold on to that. Now you need to get used to working with a group of objects. Don't rush. Maybe try something on the side to
I think we have enough information to put together the AABB collision logic. But you will have to use variables instead of hard coding your 'on hit' condition. You also need to be aware of the state of your object. We declare a couple of bools as part of our object, use them like in the pseudo code. If you don't like that design, let's redesign it.
With that said, I invite you over to my latest blog entry. Here, you'll find a code listing of how I'm handling collision in my game right now. Very different because it's goal is to generate a response when we trigger instead of what you're doing which is to make the determination in the first place and then acting on that event. Please excuse the language, it' a party and we're playing a game.
Dev careful. Pixel on board.
Buckle up. Everything will be revealed.