/robowaifu/ - DIY Robot Wives

Advancing robotics to a point where anime catgrill meidos in tiny miniskirts are a reality.

Downtime was caused by the hosting service's network going down. Should be OK now.

An issue with the Webring addon was causing Lynxchan to intermittently crash. The issue has been fixed.

Max message length: 6144

Drag files to upload or
click here to select them

Maximum 5 files / Maximum size: 20.00 MB

More

(used to delete files and postings)


They worked together tirelessly, bouncing ideas off each other and solving problems as a team.


C++ Learning Classroom Chobitsu Board owner 02/11/2023 (Sat) 02:56:07 No.19777
Keep your eyes on the prize edition • 230603 lecture; week-five (>>22899) - this week's reading assignments: PPP2 chs 08 & 09 - reading review: PPP2 ch 07 - reading preview: PPP2 ch 10 - this week's assignments () --- • This is our classroom's textbook thread: (>>18749) - you'll find a link in the OP to an archive of all the code examples therein, for your local study • This course material is primarily derived from Bjarne Stroustrup's college freshman textbook Programming -- Principles and Practice Using C++ https://www.stroustrup.com/programming.html - please obtain a copy of the book for yourself, you'll need it to complete this course successfully --- >note: if you see the thread pinned, it (should) mean we're nearby to help, so ask away! --- • I'd like to get some feedback from the class participants about this C++ programming class. Specifically, I have a few questions and I seek ideas & advice from Anons how to approach these needs: - How to best run our classroom using (only) this IB? - How to give out exercises & assignments, & receive solutions? - How to assign grades? - How to manage the asynchronous nature of IB communications, student-to-instructor (and vice versa)? - How to utilize the textbook thread well, since it (mostly) contains already-worked solutions? - How to do tests? - How to manage a final group project together? What should that project be in fact? - Any other adivce or suggestions you think would be helpful. Please post your recommendations for these topics ITT Anon, thanks! :^) --- >unless otherwise-noted, everything ITT is MIT (Expat) licensed >copyright 2023
Edited last time by Chobitsu on 06/02/2023 (Fri) 12:46:59.
Open file (169.69 KB 720x540 Slide36.png)
Open file (176.22 KB 720x540 Slide37.png)
Open file (164.58 KB 720x540 Slide38.png)
Open file (165.25 KB 720x540 Slide39.png)
Open file (164.09 KB 720x540 Slide1.png)
Open file (167.16 KB 720x540 Slide2.png)
Open file (169.60 KB 720x540 Slide3.png)
Open file (170.86 KB 720x540 Slide4.png)
Open file (177.25 KB 720x540 Slide5.png)
Open file (161.10 KB 720x540 Slide6.png)
Open file (172.34 KB 720x540 Slide7.png)
Open file (174.08 KB 720x540 Slide8.png)
Open file (176.76 KB 720x540 Slide9.png)
Open file (166.64 KB 720x540 Slide10.png)
Open file (172.14 KB 720x540 Slide11.png)
Open file (168.25 KB 720x540 Slide12.png)
Open file (169.66 KB 720x540 Slide13.png)
Open file (170.25 KB 720x540 Slide14.png)
Open file (172.59 KB 720x540 Slide15.png)
Open file (169.24 KB 720x540 Slide16.png)
Open file (172.42 KB 720x540 Slide17.png)
Open file (168.18 KB 720x540 Slide18.png)
Open file (180.54 KB 720x540 Slide19.png)
Open file (170.80 KB 720x540 Slide20.png)
Open file (168.92 KB 720x540 Slide21.png)
Open file (172.50 KB 720x540 Slide22.png)
Open file (170.03 KB 720x540 Slide23.png)
Open file (170.08 KB 720x540 Slide24.png)
Open file (171.17 KB 720x540 Slide25.png)
Open file (171.79 KB 720x540 Slide26.png)
Open file (174.19 KB 720x540 Slide27.png)
Open file (169.77 KB 720x540 Slide28.png)
Open file (171.55 KB 720x540 Slide29.png)
Open file (174.69 KB 720x540 Slide30.png)
Open file (168.23 KB 720x540 Slide31.png)
>>22801 Lecture 04 ends 14
>spare reserve
>spare reserve
>spare reserve
that's it? this is all the c++ you brainlets can write?
>>22834 Lol, this is beginner's course Anon. :^)
>>22835 tHow about everyone here makes a text based game about a robot waifu starting now and they have to finish it by the end of the month.
>>22837 Sounds like a good idea. I'll help you with it if that's what you want to do for a project Anon! :^)
>>22837 This guy speaks my language. You want to skill up to make a real-time, human-level AI some day? Drop the books and try making an 8-bit Waifugotchi first.
>>22879 >8-bit Waifugotchi Sounds fun! :^) Same offer's extended to you Anon, I'll help out with C++ information if you want to do that as a project.
>>22880 honestly I need help with freqtrade, I want to make a trading bot and im kind of stuck... that's all python though. Or you can animate the whole spritesheet, but that one is just for fun https://github.com/peteblank/yotsubee
>>22881 Haha I didn't say I'd do your work Anon, lol I have plenty of my own already! :^) But I'll honestly help you as I may if you get stuck with an honest effort. This is a classroom thread after all -- you're here to learn! Good luck with your work Anon.
Open file (164.78 KB 720x540 Slide1.png)
Open file (168.44 KB 720x540 Slide2.png)
Open file (169.46 KB 720x540 Slide3.png)
Open file (176.18 KB 720x540 Slide4.png)
Open file (170.84 KB 720x540 Slide5.png)
Lecture 05 begins 1
Open file (170.18 KB 720x540 Slide6.png)
Open file (168.37 KB 720x540 Slide7.png)
Open file (163.86 KB 720x540 Slide8.png)
Open file (167.77 KB 720x540 Slide9.png)
Open file (176.37 KB 720x540 Slide10.png)
Open file (173.73 KB 720x540 Slide11.png)
Open file (172.12 KB 720x540 Slide12.png)
Open file (166.07 KB 720x540 Slide13.png)
Open file (172.40 KB 720x540 Slide14.png)
Open file (131.60 KB 720x540 Slide15.png)
Open file (173.31 KB 720x540 Slide16.png)
Open file (170.47 KB 720x540 Slide17.png)
Open file (173.17 KB 720x540 Slide18.png)
Open file (173.80 KB 720x540 Slide19.png)
Open file (174.37 KB 720x540 Slide20.png)
Open file (167.61 KB 720x540 Slide21.png)
Open file (170.92 KB 720x540 Slide22.png)
Open file (174.26 KB 720x540 Slide23.png)
Open file (174.01 KB 720x540 Slide24.png)
Open file (171.84 KB 720x540 Slide25.png)
Open file (166.27 KB 720x540 Slide26.png)
Open file (171.05 KB 720x540 Slide27.png)
Open file (179.51 KB 720x540 Slide28.png)
Open file (171.87 KB 720x540 Slide29.png)
Open file (173.30 KB 720x540 Slide30.png)
Open file (167.97 KB 720x540 Slide31.png)
Open file (176.67 KB 720x540 Slide32.png)
Open file (164.09 KB 720x540 Slide33.png)
Open file (165.11 KB 720x540 Slide1.png)
Open file (163.57 KB 720x540 Slide2.png)
Open file (165.13 KB 720x540 Slide3.png)
Open file (177.22 KB 720x540 Slide4.png)
Open file (177.44 KB 720x540 Slide5.png)
Open file (170.51 KB 720x540 Slide6.png)
Open file (170.45 KB 720x540 Slide7.png)
Open file (170.95 KB 720x540 Slide8.png)
Open file (166.63 KB 720x540 Slide9.png)
Open file (170.57 KB 720x540 Slide10.png)
Open file (171.44 KB 720x540 Slide11.png)
Open file (173.44 KB 720x540 Slide12.png)
Open file (176.29 KB 720x540 Slide13.png)
Open file (171.80 KB 720x540 Slide14.png)
Open file (169.29 KB 720x540 Slide15.png)
Open file (175.32 KB 720x540 Slide16.png)
Open file (175.90 KB 720x540 Slide17.png)
Open file (171.90 KB 720x540 Slide18.png)
Open file (173.88 KB 720x540 Slide19.png)
Open file (171.43 KB 720x540 Slide20.png)
Open file (172.92 KB 720x540 Slide21.png)
Open file (166.37 KB 720x540 Slide22.png)
Open file (171.01 KB 720x540 Slide23.png)
Open file (168.03 KB 720x540 Slide24.png)
Open file (172.48 KB 720x540 Slide25.png)
Open file (168.39 KB 720x540 Slide26.png)
Open file (172.81 KB 720x540 Slide27.png)
Open file (173.22 KB 720x540 Slide28.png)
Open file (172.95 KB 720x540 Slide29.png)
Open file (172.63 KB 720x540 Slide30.png)
Open file (175.03 KB 720x540 Slide31.png)
>>22910 Lecture 05 ends 13
>spare reserve
>spare reserve
>spare reserve
>>22882 The honest effort is me animating the first row
>>22917 Well, let's see what you've managed so far (the code please) and we'll come up with a plan for it.
Open file (534.00 B 16x24 Untitled.gif)
Open file (544.00 B 16x24 Untitled2.gif)
>>22921 I posted the github page
>>22950 Oh, haha. Fair enough I suppose, thanks! But can you please just post the pertinent animation-related codeblock here ITT if you would Anon? That'll be much quicker for me, and is generally in line with the way to do things with our own textbook work. TIA. BTW, this page has information about using codeblocks correctly here. https://alogs.space/.static/pages/posting.html
>>22955 sure here it is /******************************************************************************************* * * raylib [textures] example - Sprite animation * * Example originally created with raylib 1.3, last time updated with raylib 1.3 * * Example licensed under an unmodified zlib/libpng license, which is an OSI-certified, * BSD-like license that allows static linking with closed source software * * Copyright (c) 2014-2023 Ramon Santamaria (@raysan5) * ********************************************************************************************/ #include "../include/raylib.h" #define MAX_FRAME_SPEED 15 #define MIN_FRAME_SPEED 1 //------------------------------------------------------------------------------------ // Program main entry point //------------------------------------------------------------------------------------ int main(void) { // Initialization //-------------------------------------------------------------------------------------- const int screenWidth = 800; const int screenHeight = 450; InitWindow(screenWidth, screenHeight, "raylib [texture] example - sprite anim"); // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) Texture2D scarfy = LoadTexture("src/assets/Yotsuba_SpriteSheet.png"); // Texture loading /* fixed the path */ Vector2 position = { 350.0f, 280.0f }; Rectangle frameRec = { (float)scarfy.width, 0.0f, (float)24, (float)scarfy.height/4 }; int currentFrame = 0; int framesCounter = 0; int framesSpeed = 8; // Number of spritesheet frames shown by second SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop while (!WindowShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- framesCounter++; if (framesCounter >= (60/framesSpeed)) { framesCounter = 0; currentFrame++; if (currentFrame > 2) currentFrame = 0; frameRec.x = (float)currentFrame*(float)scarfy.width/3; } // Control frames speed if (IsKeyPressed(KEY_RIGHT)) framesSpeed++; else if (IsKeyPressed(KEY_LEFT)) framesSpeed--; if (framesSpeed > MAX_FRAME_SPEED) framesSpeed = MAX_FRAME_SPEED; else if (framesSpeed < MIN_FRAME_SPEED) framesSpeed = MIN_FRAME_SPEED; //---------------------------------------------------------------------------------- // Draw //---------------------------------------------------------------------------------- BeginDrawing(); ClearBackground(RAYWHITE); DrawTexture(scarfy, 0, 40, WHITE); DrawRectangleLines(0, 40, scarfy.width, scarfy.height, LIME); DrawRectangleLines(6 + (int)frameRec.x, 40 + (int)frameRec.y, (int)frameRec.width, (int)frameRec.height, RED); DrawText("FRAME SPEED: ", 165, 210, 10, DARKGRAY); DrawText(TextFormat("%02i FPS", framesSpeed), 575, 210, 10, DARKGRAY); DrawText("PRESS RIGHT/LEFT KEYS to CHANGE SPEED!", 290, 240, 10, DARKGRAY); for (int i = 0; i < MAX_FRAME_SPEED; i++) { if (i < framesSpeed) DrawRectangle(250 + 21*i, 205, 20, 20, RED); DrawRectangleLines(250 + 21*i, 205, 20, 20, MAROON); } DrawTextureRec(scarfy, frameRec, position, WHITE); // Draw part of the texture DrawText("(c) Scarfy sprite by Eiden Marsal", screenWidth - 200, screenHeight - 20, 10, GRAY); EndDrawing(); //---------------------------------------------------------------------------------- } // De-Initialization //-------------------------------------------------------------------------------------- UnloadTexture(scarfy); // Texture unloading CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- return 0; }
>>22957 Got it, thanks Anon. Here's my initial suggested fix: // Main game loop while (! WindowShouldClose()) { // Detect window close button or ESC key // Update //-------------------------------------------------------------------------- framesCounter++; if (framesCounter >= (60 / framesSpeed)) { framesCounter = 0; currentFrame++; if (currentFrame > 2) currentFrame = 0; frameRec.x = (float)currentFrame * (float)scarfy.width / 3; // TODO: adjust your frameRec.y here? } Please let us know if this modification helps.
>>22958 eh thank you ill try it later
>>22958 or even simpler while (!WindowShouldClose()) { currentFrame %= 3; frameRec.x = (float)currentFrame * (float)scarfy.width / 3; usleep( 1000000/framesSpeed ); }
>>22962 that's neat and all but it didn't solve the problem. But I did it. gg. while (!WindowShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- framesCounter++; if (framesCounter >= (60/framesSpeed)) { framesCounter = 0; currentFrame++; if (currentFrame > 2) {currentFrame = 0; frameRec.y+=scarfy.height/4; if (frameRec.y >scarfy.height/4*3) { frameRec.y = 0; } } currentFrame %= 3; frameRec.x = (float)currentFrame * (float)scarfy.width / 3; }
>>22962 Yep modulo is a good choice, but I'm unsure that the sleep will help much. Thanks Anon! >>22964 Great! Full marks Anon. Now, I'd suggest you enhance your system in two ways: 1. Replace this if/else pair with tests for '+' key (plus), and '-' key (minus), instead to control the rate of animation. // Control frames speed if (IsKeyPressed(KEY_RIGHT)) framesSpeed++; else if (IsKeyPressed(KEY_LEFT)) framesSpeed--; 2. Now test all four direction keys, and this time use them to choose which row of your sprite sheet to animate (left, right, up, down) instead. Do these two steps and you'll be very close to an animated Yotsuba geimu character. Cheers. :^) >=== -prose edit
Edited last time by Chobitsu on 06/05/2023 (Mon) 16:20:36.
>>22965 >unsure that the sleep will help much because if (framesCounter >= (60 / framesSpeed)) makes no sense in a loop, framesCounter will be incremented as fast as the cpu can run its not time related the only way to do something in a timed interval is with the actual time functions not a counter, this only works because the library functions, which have proper timing/syncing, act as a bottleneck
>>22966 I see your point Anon. At the least, the call while (! WindowShouldClose()) { ... } should allow the system to do polling for the rest of the work to be done outside the gameloop (user input, file/net I/O, etc). And the draw() call bookends likely serve a similar function around that block of code. >tl;dr The Raylib library is already allowing for a responsive system. IMO, intentionally injecting a wait is probably unhelpful in general in a game (outside an intentional 'pause' system).
>>22964 >>22965 BTW, when you need to handle a lot of things that are similar, it's a more-typical (good) practice to do so inside a switch() statement. Here's my recommendation to you how to do so, just to get you pointed in the right direction Anon: >main.cpp snippet: switch (GetKeyPressed()) { case KEY_KP_ADD: { framesSpeed++; if (framesSpeed > max_frame_speed) framesSpeed = max_frame_speed; break; } case KEY_KP_SUBTRACT: { framesSpeed--; if (framesSpeed < min_frame_speed) framesSpeed = min_frame_speed; break; } // TODO: add your directional key handler code statements here... default:; // nop (for now) } You can find the enumeration of all the available keypress definitions in the include/raylib.h file, and beginning around line #520. Good luck Anon! :^) >=== -patch crosslink
Edited last time by Chobitsu on 06/07/2023 (Wed) 12:31:30.
>>22987 for simple arithmetic you wouldnt use any branching at all really key = GetKeyPressed(); framespeed += (key == KEY_KP_ADD) & (framespeed < max); framespeed -= (key == KEY_KP_SUBTRACT) & (framespeed > min);
>>22988 Good, efficient logic Anon. I like the form. But we're still in a beginner's classroom thread, so it's better to take a couple-nanosecond speed hit, for clarity of reasoning for the novice. But again, nice work! :^)

Report/Delete/Moderation Forms
Delete
Report