Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 days ago.
Improve this question
I need a very simple example in C, using the XCB library. With a simple window that, when moved, shows its x and y position in the title or terminal. One event that works to capture motion is XCB_CONFIGURE_NOTIFY.
Preferably counting its borders and title, that is, that when I position it in the upper left corner it actually marks 0,0.
My difficulty started the moment everything I tried only displays 0.0 in any position or at most 5.19 in the top left corner.
NOTE:
Please, don't use examples of Xlib or any other library that someone's imagination has. I want to learn XCB!
Examples only in the C language, remembering that C is not C++.
For those who want to know why: NONE important! What comes to mind at this moment is being able to see on my screen what size I imagine I'll need for something else, because for me this is just basic!
And no, I don't want to use a ruler on the screen to know the size of my window :)
I tried several like: xcb_get_geometry (All), xcb_translate_coordinates, xcb_configure_notify_event_t, xcb_expose_event_t
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
Disclaimer: I’ve never used C before a few weeks ago, and I’m somewhat new to programming in general.
I’m writing a really basic space invaders type game in C. We have a little motherboard with a screen, joystick and buttons to port it to. I’m far from done but how it currently works is this:
-the character can move around the bottom of the screen from left to right with the joystick
-when the button is pressed, it creates a bullet right above his head that moves up to the top then vanishes
Now here’s where there’s a problem. In order to make the bullet spawn right above his head, I had to use the x coordinate of the character to define where to create the bullet. These are stored in variables, which are modified in the joystick code whenever the joystick is moved.
The movement of the bullet occurs like this: a black square quickly covers up the bullet, and a new bullet is drawn just above it. This repeats until the bullet hits the top.
So, the problem is that the bullet moves about the x-axis just like the character does. This is because all the rectangles for the bullet’s “movement” are defined such that their x coordinate is the variable of the Character’s x coordinate, which of course changes with the joystick.
so my question is this: is it possible in C to extract the INSTANT, integer value of a variable? For example, if I can nab the instant value of the character’s x-coordinate when the first rectangle of the bullet is created, then re-use that unchanging integer (as another variable) for the x-coordinate for subsequent rectangles, it will appear as if the movement of the bullet is straight up, despite the character still moving about.
TLDR: Is it possible in C to extract the instant integer value of an often-changing variable and store it in another variable for temporary use?
Yes of course. Put the assignment in a code block that will only be executed when the button is pressed. This way the bullets x position won't be updated until you shoot again.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I creating LogLogarithmicAxis-log(log()) referring to OxyPlot's LogarithmicAxis -log()
this is my code
OxyPlot.Axes.LogLogarithmicAxis.cs
OxyPlot.Wpf.LogLogarithmicAxis.cs
Examples/ExampleLibrary/Axes/LogarithmicAxisExamples.cs
chart image by code :
chart image
but i need this style :
chart image
Comparing the two chart images, Tick and Label on Y axis are different.
how to coding...help..
Please add a minimal, complete and viable example. And embed your code and images in the question. Someday you will remove the files from your google drive and the question won't be of help to anyone.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I have a WPF application that needs to provide feedback to the user. I use a WPF window (progress window) with couple of Progress bars that I tried to update using:
Calling a method on the progress window and change the values of program bars
Binding the value of progress bars to a ModelView
Both perform the same.
[Demonstration Application Download][1]
The performance is really slow if I update the progress values every time through the loop. It gets better depending upon how often I update the progress value.
The Demonstration Application gives me the following times:
Interval Overall Loop Time
1 23:46 seconds
10 3:09 seconds
100 :42 seconds
1000 :05 seconds
I would like to report progress every time through the processing loop. How can that be done?
In my "real" application the processing loop does a lot of processing but updating the progressbar for each unit of work is slow.
A general approach to designing well behaved applications that need to do processing is that the work should be done on another thread, with periodic messages posted back to the UI to update it on progress. BackgroundWorker may suit your application - https://msdn.microsoft.com/en-us/library/cc221403%28v=vs.95%29.aspx?f=255&MSPPError=-2147217396
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I'm coding a game like agar.io and I want to create a world like 5000x5000 but for example player can see only 900x600 part.
Namely player must have a scope. My background is not a bitmap, I'm basicaly make backbuffer black, draw primitives on it and flip it.
How can I do this?
It sounds like transforms could help you out here.
Basically, you have a 900x600 display (al_create_display(900, 600)), but let your objects have positions anywhere in the 5000x5000 space.
When your player moves, you shift the camera transformation along with them. Your draw loop might look like this:
al_clear_to_color(al_map_rgb(0,0,0));
ALLEGRO_TRANSFORM trans;
al_identity_transform(&trans);
al_translate_transform(&trans, -player_x, -player_y);
al_use_transform(&trans);
// draw the player
al_draw_filled_circle(player_x + SCREEN_W / 2, player_y + SCREEN_H / 2,
32, al_map_rgb(255,0,0));
// draw all other entities
// ....
al_flip_display();
Note that the camera is shifted by -player_x,-player_y. If the player is at
(1000, 1000), an object at (1500, 1500) should be drawn at
(1500-1000,1500-1000), or (500,500) relative to the player. An object at (500,
500) would be drawn at (500-1000,500-1000) or (-500,-500); it will be
off-screen.
We don't actually have to perform this subtracion for every object though. You just draw every object at its absolute position, and the transform will translate it to a position relative to the player (the player's 'local' space).
Note also that we add half the screen size so the player is centered.
There are a number of ways to approach this, but the above should give you a
good start. As a bonus, using transforms makes it easy to add things like zoom
and rotation.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I'm an Amiga programming newbie.
I need to produce an application that displays graphics in a similar way to the popular drawing application, Deluxe Paint by Dan Silva, published by Electronic Arts. Just a vertically scrolling image, preferably in HAM mode.
How do I open a new screen based on the result from a screenmode requester dialogue box using HiSoft C for the Amiga?
Requirements:
Open a new hires interlaced screen in as many colours as hardware will allow
Basic menu structure that I can manipulate (Top Right-click menu)
A project window, similar to the HiSoft C editor
A control panel along the top similar to the one in Digita Wordworth with text boxes, buttons and tabs
I also need an off screen buffer that is as wide as the screen and as tall as memory will allow.
This needs to be compatible with:
Workbench 3.0 and above
68020 and above
ECS & AGA chipset
0.5..2Mb chipmem + 0..∞ fastmem
From the question, I'm not sure how experienced you are with Amiga programming. If you have zero experience with the way windows and screens are set up, then I can strongly recommend Anders Bjerin's Amiga C Manual
It's fairly old and predates AGA, but it shouldn't be a huge problem to extrapolate how to open a 256 colour screen.