well your code looks very similar to mine just with a few minor tweaks, I am getting better at my coding skills. sometimes I just need a little help.
c# drawing sprites
I am still studying my book and doing the exercises, this chapter is on arrays, hopefully this will help in my coding. also I am still working on my coding problem as explained above.
I wrote this today for play while I'm testing something new (Esenthel) It's just a little sequence that runs during six seconds allowed for an intro screen in the works. It's crude and slightly different structure, but the idea is all there for a simple little thing. Check it out, maybe port it to your environment. (it's a good exercise, maybe make it better)
struct IntroContainer
{
Vec2 pos;
Vec2 accel;
float radius = 0.1;
bool broken = false;
};
IntroContainer introContainer[5];
bool InitIntro()
{
introContainer[0].pos = {-0.5, 0.5};
introContainer[0].accel = { 1.5, 1.0};
introContainer[1].pos = { 0.5, 0.3};
introContainer[1].accel = {-1.5, 0.7};
introContainer[2].pos = {-0.7, 0.4};
introContainer[2].accel = { 1.2, 0.9};
introContainer[3].pos = { 0.7, 0.4};
introContainer[3].accel = {-1.2, 0.9};
introContainer[4].pos = {-1.0, 0.2};
introContainer[4].accel = { 1.2, -1.4};
return true;
}
void ShutIntro()
{
}
bool UpdateIntro()
{
if(Time.stateTime()>6 || Kb.bp(KB_ESC)) // if active state (which here is 'StateIntro') is running for more than 3 seconds or escape pressed
StateMenu.set(1.0); // then switch to 'StateMenu' state with 1.0 second smooth fading
for( int id=0; id<5; id++)
{
introContainer[id].pos.y -= 0.001;
introContainer[id].accel *= 0.99;
introContainer[id].pos += introContainer[id].accel * 0.01;
for(int other=0; other<5; other++)
{
if(id == other) { continue; }
// check against the other
float distX = (introContainer[id].pos.x - introContainer[other].pos.x);
float distY = (introContainer[id].pos.y - introContainer[other].pos.y);
float dist = Sqrt(distX*distX + distY * distY);
if(dist < (introContainer[id].radius + introContainer[other].radius))
{
// collision (fake a reaction)
introContainer[id].accel *= -0.4;
introContainer[other].accel *= -0.4;
introContainer[other].pos -= dist;
introContainer[id].broken = true;
introContainer[id].radius *= 0.7;
introContainer[other].broken = true;
introContainer[other].radius *= 0.7;
}
}
}
return true;
}
// sloppy test variables
float c1y_modifier = -0.05; // add some variance
float c2y_modifier = 0.1;
bool toggle = false;
float textPosY = 0.2;
int textColor = 255;
void DrawIntro()
{
D.clear(BLACK);
// Fade out text
TextStyleParams ts;
ts.color = Color(textColor);
D.text (ts, 0, textPosY-=0.001, "Goliath Forge Online");
D.text(ts, 0, textPosY - 0.08, "My 2019 Games");
textColor -= 1; if(textColor < 0) textColor = 0;
// Run a simple ball simulation
for(int id=0; id<5; id++)
{
if(introContainer[id].broken == true)
{
Circle(introContainer[id].radius, introContainer[id].pos).draw(RED, false);
if(toggle)
Circle(introContainer[id].radius, introContainer[id].pos + Vec2(-0.14, c1y_modifier)).draw(RED, false);
else
Circle(introContainer[id].radius, introContainer[id].pos + Vec2(-0.14, c2y_modifier)).draw(RED, false);
c1y_modifier -= 0.001;
c2y_modifier -= 0.002;
introContainer[id].radius *= 0.99;
}
else
{
Circle(introContainer[id].radius, introContainer[id].pos).draw(RED, false);
}
}
}
Circle is a build in drawing function in my environment, in this case not flood filled but red. Text is also a built in for me.
Works fine on my machine. What am I doing wrong? Will it run the exact same on your machine? First thing I do when I update is look at something. But then never use it...Do you know what we're not scaling all this math by?
Dev careful. Pixel on board.
Buckle up. Everything will be revealed.
well that is some nice code, but it is a little beyond me at this time, that is why I am still studying c#
yes, of course. Good day.
Dev careful. Pixel on board.
Buckle up. Everything will be revealed.
I guess not. Thank you.
Dev careful. Pixel on board.
Buckle up. Everything will be revealed.