TheRanger
TheRanger
CC#
Created by Manu on 11/8/2024 in #help
Pokemon Game SRP
or if u want to apply SRP you could put it in a class called DamageCalculator
23 replies
CC#
Created by Manu on 11/8/2024 in #help
Pokemon Game SRP
yes it should be only a single method, you can call it TakeDamage or something that has a parameter of Pokemon
23 replies
CC#
Created by Manu on 11/8/2024 in #help
Pokemon Game SRP
atleast make Estado an enum, this way you can have named integers
23 replies
CC#
Created by Manu on 11/8/2024 in #help
Pokemon Game SRP
23 replies
CC#
Created by Manu on 11/8/2024 in #help
Pokemon Game SRP
yeah there are formulas online on how to calculate a pokemon taking damage
23 replies
CC#
Created by Manu on 11/8/2024 in #help
Pokemon Game SRP
What did you try so far, can you show some code?
23 replies
CC#
Created by shinystar on 11/4/2024 in #help
✅ Looking for a developer
$rule6
4 replies
CC#
Created by blunt on 10/29/2024 in #help
✅ variable wont change
$debug
40 replies
CC#
Created by blunt on 10/29/2024 in #help
✅ variable wont change
what is, vars.betting?
40 replies
CC#
Created by blunt on 10/29/2024 in #help
✅ variable wont change
did it print that?
40 replies
CC#
Created by blunt on 10/29/2024 in #help
✅ variable wont change
well u already did with Console.WriteLine("your number is lower! you lose");
40 replies
CC#
Created by blunt on 10/29/2024 in #help
✅ variable wont change
you can debug, set breakpoints, or even put Console.WriteLine to make sure it was executed
40 replies
CC#
Created by blunt on 10/29/2024 in #help
✅ variable wont change
did you make sure the if condition of that code returned true?
40 replies
CC#
Created by blunt on 10/29/2024 in #help
✅ variable wont change
where is vars.money in ur code
40 replies
CC#
Created by blunt on 10/29/2024 in #help
✅ variable wont change
well maybe vars.betAmount is 0
40 replies
CC#
Created by blunt on 10/29/2024 in #help
✅ variable wont change
can u show the declaration of vars.money ?
40 replies
CC#
Created by ☆ nubbs ☆ on 10/28/2024 in #help
per pixel collision
i need to go, maybe we continue tomorrow
95 replies
CC#
Created by ☆ nubbs ☆ on 10/28/2024 in #help
per pixel collision
public bool PerPixelCollision(LandEnemy eggpawn)
{
// get their sprite based on their current frame in their current animation
var sonicsCurrentSprite = GetSprite();
var eggpawnsCurrentSprite = eggpawn.GetSprite();

// their rectangle in world space whose size should be the same as their current sprite's size
var sonicsRectangle = GetRectangle();
var eggpawnsRectangle = GetRectangle();

// no intersection, return false
if (!sonicsRectangle.Intersects(eggpawnsRectangle))
{
return false;
}

// get the new rectangle that contains overlapping region of two other rectangles.
var intersectedRectangle = Rectangle.Intersect(sonicsRectangle, eggpawnsRectangle);

for(int y = intersectedRectangle.Top; y <= intersecretRectangle.Bottom; y++)
{
for(int x = intersectedRectangle.Left; x <= intersecretRectangle.Right; x++)
{
// do some math to get the local coordinates of x,y in their rectangle (the method below doesnt exist, you can create one as an extension method for the Rectangle class or put it in a static class and call it RectangleUtility)
Vector2 sonic = sonicRectangle.GetLocalPosition(x, y);
Vector2 enemy = eggpawnsRectangle.GetLocalPosition(x, y);

if (sonicsCurrentSprite.HasPixel(sonic) && eggpawnsCurrentSprite.HasPixel(enemy))
{
return true;
}
}
}
return false;
}
public bool PerPixelCollision(LandEnemy eggpawn)
{
// get their sprite based on their current frame in their current animation
var sonicsCurrentSprite = GetSprite();
var eggpawnsCurrentSprite = eggpawn.GetSprite();

// their rectangle in world space whose size should be the same as their current sprite's size
var sonicsRectangle = GetRectangle();
var eggpawnsRectangle = GetRectangle();

// no intersection, return false
if (!sonicsRectangle.Intersects(eggpawnsRectangle))
{
return false;
}

// get the new rectangle that contains overlapping region of two other rectangles.
var intersectedRectangle = Rectangle.Intersect(sonicsRectangle, eggpawnsRectangle);

for(int y = intersectedRectangle.Top; y <= intersecretRectangle.Bottom; y++)
{
for(int x = intersectedRectangle.Left; x <= intersecretRectangle.Right; x++)
{
// do some math to get the local coordinates of x,y in their rectangle (the method below doesnt exist, you can create one as an extension method for the Rectangle class or put it in a static class and call it RectangleUtility)
Vector2 sonic = sonicRectangle.GetLocalPosition(x, y);
Vector2 enemy = eggpawnsRectangle.GetLocalPosition(x, y);

if (sonicsCurrentSprite.HasPixel(sonic) && eggpawnsCurrentSprite.HasPixel(enemy))
{
return true;
}
}
}
return false;
}
95 replies
CC#
Created by ☆ nubbs ☆ on 10/28/2024 in #help
per pixel collision
public class Sprite
{
public Rectangle rectangle; // location of the sprite and its size in the texture
bool[] _pixelCollision;

// constructor and some useful methods

public void InitializePixelCollisionArray(Texture2D texture)
{
Color[] colors = new Color[texture.Width * texture.Height];
_pixelCollision = new bool[colors.Length];


texture.GetData(0, rectangle, colors, 0, colors.Length); // gets the colors of the area indicated by the rectangle

for(int i = 0; i < _pixelCollision.Length; i++)
{
if (colors[i].A > 0)
{
_pixelCollision[i] = true;
}
}
}

// methods you can put for accessing pixels
public bool HasPixel(int x, int y)
{
return _pixelCollision[y * rectangle.Width + x];
}
public bool HasPixel(Vector2 vec)
{
return HasPixel(vec.X, vec.Y);
}
}
public class Sprite
{
public Rectangle rectangle; // location of the sprite and its size in the texture
bool[] _pixelCollision;

// constructor and some useful methods

public void InitializePixelCollisionArray(Texture2D texture)
{
Color[] colors = new Color[texture.Width * texture.Height];
_pixelCollision = new bool[colors.Length];


texture.GetData(0, rectangle, colors, 0, colors.Length); // gets the colors of the area indicated by the rectangle

for(int i = 0; i < _pixelCollision.Length; i++)
{
if (colors[i].A > 0)
{
_pixelCollision[i] = true;
}
}
}

// methods you can put for accessing pixels
public bool HasPixel(int x, int y)
{
return _pixelCollision[y * rectangle.Width + x];
}
public bool HasPixel(Vector2 vec)
{
return HasPixel(vec.X, vec.Y);
}
}
95 replies
CC#
Created by ☆ nubbs ☆ on 10/28/2024 in #help
per pixel collision
and it should be fine to store the pixel collision array into it
95 replies