Android Development.

Shadowprophet

Truthiness
Hey guys, I know there are a few devs around. I've been going at it full force learning what I can do in android development. That said, there are developers here that know this stuff better than I do so ill get this question out of the way real quick.

Apache commons. What is the best library to really go with here? There are a gigazillion of them and they are all very specifically designed for different functions.

If you guys know some good git sources for some great libraries or tool chains , id love that.

Also on to android development,. Its literally just java with extra steps so. You know , nothing really to comment on rather than the structure has a hybrid file system that likes to get a build gradle involved,. The best way to describe a build gradle is

programs have structures they are designed to break functions off into different sections to make the code run more efficiently. Usually in java you have your xml your java main file and and your assets and so on in html you can just throw your java and css right in there, html is cool that way.

but in android development you seem to have this build gradle that seems to function much like html,. In that, you can throw your xml and java and css all in the gradle and it tends to sort it out for you. You would think that would make things easier . It only serves to confuse

anyway, the real problem im having right now is I need to find a 64 bit NDK. I can only find the older 32 bit and the deal is my phone is 64 bit only cause google did away with the 32 bit arm support in the pixel phones for some reason. I think it has to do with the tensor 2 not supporting 32 bit arm. Anyway. A 64 bit NDK must exist. So if anyone runs into one, please let me know. Sp.
..
 
Last edited:

Shadowprophet

Truthiness
Im posting something quick and out of the way here,.

Im using an IDE called Replit. Its an online development environment. You know, for anyone interested, there has never been a better time to learn to code. There are so many resources and so many ways to learn.

I mean,. I only code like five or six minuets at a time throughout the day, I've literally coded while waiting for the taco bell lady to bring our food to us.

Tate says he wont learn to code because hitting several brick walls a day tends to rage him out.

I don't know,. I mean life is a challenge anyway. No matter what path one chooses in life , there will be challenges,. So embrace challenge,. Overcome challenge, if there is something in life you believe you could never learn or never achieve, that is exactly what you should be pursuing. Life is too short to waste it...

Anyway, l've rambled long enough.

This block of code is fundamentally useless unless you have the assets and files and the ide set up to perfectly match mine,. But , I need a place to store this code block.

My backups on Replit keep getting overwritten because of sync issues so i need a stable place to store a backup code that wont corrupt or change over time.

Just explaining why id post what seems to be garbage gobbledygook.

kaboom({
widthwidth: 1920,
heightheight: 1080,
});

// Load assets
loadSound("bgm", "/paintitblack.mp3");
loadSprite("enea", "/enea.png");
loadSprite("metor", "/wing.png");
loadSprite("background", "/nebula.jpg");
loadSprite("dmgs", "/dmgs.png");
loadSprite("dmga", "/dmga.png");
loadSprite("dmgm", "/dmgm.png");
loadSprite("bloodmoon", "/bloodmoon.png");
loadSprite("castle", "/cas.png");
loadSprite("phb", "/playerhealth.png");
loadSprite("ehb", "/enemyhealth.png");

const music = play("bgm");
music.loop = true;

function addButton(txt, p, f) {
const btn = add([
rect(100, 50, { radius: 8 }),
pos(p),
area(),
scale(1),
anchor("center"),
outline(4),
]);

btn.add([
text(txt),
anchor("center"),
color(0, 0, 0),
]);

btn.onHoverUpdate(() => {
const t = time() * 10;
btn.color = hsl2rgb((t / 10) % 1, 0.6, 0.7);
btn.scale = vec2(1.2);
setCursor("pointer");
});

btn.onHoverEnd(() => {
btn.scale = vec2(1);
btn.color = rgb();
});

btn.onClick(f);
return btn;
};

let player;
let hp;
let enemy;
let enemyhp;

function isAlive(entity) {
return entity.hp > 0;
}

// Function to update health bar visuals based on current health
function updateHealthBar(healthBar, currentHP, maxHP) {
const healthRatio = currentHP / maxHP;
const healthBarWidth = 500; // Adjust this width based on the maximum health value

// Calculate the width of the health bar based on the health ratio
const newWidth = healthRatio * healthBarWidth;

// Update the sprite component of the health bar entity to reflect the new width
healthBar.use(sprite(`phb_${Math.ceil(healthRatio * 5)}`)); // Assuming you have images named phb_1, phb_2, phb_3, phb_4, phb_5 representing different health levels
healthBar.width = newWidth;
}

// Create the battle scene
scene("battle", () => {
// ... (Scene setup code)

// Display the background
add([
sprite("background"),
z(0),
width(1920),
height(1080),
scale(1.9),
]);
// Display the battle menu
// Add the Attack button
addButton("Attack", vec2(5, 200), () =>
{
console.log("Attack button clicked!");
handleAttack("attack");
if (isAlive(enemy) && isAlive(player));
});

// Add the Defend button
addButton("Defend", vec2(200, 200), () => {
console.log("Defend button clicked!");
handleAttack("defend");
});


let isDefending = false;
const metor = add([
sprite("metor"),
width(170),
height(200),
pos(0, 0),
area(),
scale(1),
move(50, 55),
]);

const castle = add([
sprite("castle"),
width(720),
height(1080),
fixed(),
scale(1.2),
z(99),
]);


const bloodmoon = add([
sprite("bloodmoon"),
width(270),
height(480),
pos(-64, 100),
area(),
scale(1.7),
move(269 ,31),
z(98),
]);

setTimeout(() => {
bloodmoon.use(move(70, -0)); // Stop the movement of bloodmoon after 3 seconds
}, 22000);

// Display the player character
const player = add([
sprite("dmgs"),
width(30),
height(40),
pos(110, 220),
scale(0.2),
z(102),
{
hp: 500,
maxHP: 500,
},
]);

// Display the enemy character
const enemy = add([
sprite("enea"),
pos(83, 125),
scale(0.2),
z(106),
{
hp: 500,
maxHP: 500,
},
]);

// Health Bar for Player
const playerhp = add([
sprite("phb"), // You should provide a sprite when creating the health bar
pos(0, 530),
scale(0.2),
z(110),
{
hp: player.hp,
maxHP: player.maxHP,
},
]);

// Health Bar for Enemy
const enemyhp = add([
sprite("ehb"), // You should provide a sprite when creating the health bar
pos(0, -30),
scale(0.2),
z(110),
{
hp: enemy.hp,
maxHP: enemy.maxHP,
},
]);


// Now that playerhp and enemyhp are defined, you can call updateHealthBar
updateHealthBar(playerhp, player.hp, player.maxHP);
updateHealthBar(enemyhp, enemy.hp, enemy.maxHP);


// ... (Other code)

// Implement battle logic for attack action
function handleAttack(action) {
try { // Check if the enemy is still alive and the player can attack
if (isAlive(enemy)){ console.log("Player attacks!");
}


// Implement attack logic here
let damage = 20; // Default damage value

if (action === "defend") {
// If the player chose to defend, reduce incoming damage by half
damage /= 2;
isDefending = true; // Set defending state
} else {
isDefending = false; // Reset defending state
}

// Reduce enemy's health
enemy.hp -= damage;

// Cap enemy's health at zero
if (enemy.hp < 0) {
enemy.hp = 0;
}


// Check if the enemy has been defeated
if (enemy.hp <= 0) {
// Enemy defeated - implement your logic here (e.g., show victory message, move to a new level, etc.)
console.log("Enemy defeated!");
// You can add more actions, such as increasing player experience points, etc.
} else {
// Enemy survived the attack - implement any additional logic here (e.g., enemy's counter-attack)
console.log("Enemy survived the attack!");

// Enemy's turn to attack the player
setTimeout(() => {
enemyTurn();
}, 1000);
// Add a visual effect to the player's health bar (e.g., changing color)
if (action === "attack") {
// Change the color to indicate damage taken (e.g., to red)
playerhp.color = rgb(255, 0, 0);
// Reset the color after a short delay (e.g., 0.5 seconds)
setTimeout(() => {
playerhp.color = rgb(255, 255, 255); // Reset the color to white (or any other color you prefer)
}, 500);
}
}

// Add a delay of 1 second before the enemy attacks (adjust as needed)


} catch (error) {
console.error('error ' ,error);
}
}

// Update the player's health bar
updateHealthBar(playerhp, player.hp, player.maxHP);



// Function to handle enemy behavior during its turn
// Function to handle enemy behavior during its turn
function enemyTurn() {
// Check if the player is still alive
if (isAlive(player)) {
// Implement enemy decision-making logic here
// For simplicity, let's assume the enemy always attacks the player
const damage = 30; // You can customize the damage value as needed
player.hp -= damage;
}

// Cap player's health at zero
if (player.hp < 0) {
player.hp = 0;
}

// Update the player's health bar
updateHealthBar(playerhp, player.hp, player.maxHP);

// Check if the player has been defeated
if (player.hp <= 0) {
// Player defeated - implement your logic here (e.g., show game over screen, etc.)
console.log("Player defeated!");
// You can add more actions, such as restarting the game or going back to the main menu.
} else {
// Player still has health - implement any additional logic here (e.g., show player's health bar, etc.)
console.log("Player's turn!");
// You can add more actions, such as displaying the player's health bar, waiting for player input, etc.
}
}


function updateHealthBar(healthBar, currentHP, maxHP) {
const healthRatio = currentHP / maxHP;
const healthBarWidth = 500; // Adjust this width based on the maximum health value

// Calculate the width of the health bar based on the health ratio
const newWidth = healthRatio * healthBarWidth;

// Update the sprite component of the health bar entity to reflect the new width
healthBar.width = newWidth;

// Add an effect to show damage taken (e.g., by changing the color or alpha of the health bar)
if (currentHP < maxHP) {
// For example, you can set the alpha of the health bar to indicate damage taken
healthBar.color.a = 0.8; // Set the alpha to 0.8 (adjust as needed)
} else {
// If the health is at maximum, reset the alpha to 1 (fully visible)
//healthBar.color.a = 1;
}
}

// ... (Other code)





// Update the enemy's health bar
//updateHealthBar(enemyhp, enemy.hp, enemy.maxHP);


// Register click event on canvas
const canvas = document.querySelector("canvas");



// Implement other menu options click handling if needed
;
// Implement other menu options click handling if needed


})

// Start the game by calling the battle scene
go("battle");

Im telling ya, i've worked so hard on this. My own art , my own music and sounds. This will be my thus far, magnum opus, if i ever finish it.
 
Last edited:

Shadowprophet

Truthiness
I don't know if I will ever "finish" it. Its a process I enjoy doing, I don't really want to actually be done with it. Im going to keep polishing it and refining it till its not just good, Ill work on this Untill its something engaging to the player, something that you wouldn't expect from a typical turn based rpg.
 
Top